From 969e945a9e6df7da5504a905cfbd1a6328c3b964 Mon Sep 17 00:00:00 2001 From: deads2k Date: Mon, 24 Oct 2016 10:57:50 -0400 Subject: [PATCH] delete non-generated client --- hack/.linted_packages | 1 + pkg/client/unversioned/apps.go | 55 -- pkg/client/unversioned/authentication.go | 77 --- pkg/client/unversioned/authorization.go | 77 --- pkg/client/unversioned/autoscaling.go | 55 -- pkg/client/unversioned/batch.go | 60 -- pkg/client/unversioned/certificates.go | 69 --- .../unversioned/certificatesigningrequests.go | 104 ---- pkg/client/unversioned/client.go | 202 ------- pkg/client/unversioned/clusterrolebindings.go | 92 --- pkg/client/unversioned/clusterroles.go | 92 --- pkg/client/unversioned/componentstatuses.go | 60 -- pkg/client/unversioned/configmap.go | 122 ---- pkg/client/unversioned/containerinfo.go | 123 ---- pkg/client/unversioned/containerinfo_test.go | 198 ------- pkg/client/unversioned/daemon_sets.go | 100 ---- pkg/client/unversioned/daemon_sets_test.go | 198 ------- pkg/client/unversioned/deployment.go | 111 ---- pkg/client/unversioned/deployment_test.go | 236 -------- pkg/client/unversioned/doc.go | 58 -- pkg/client/unversioned/endpoints.go | 101 ---- pkg/client/unversioned/endpoints_test.go | 71 --- pkg/client/unversioned/events.go | 219 ------- pkg/client/unversioned/events_test.go | 206 ------- pkg/client/unversioned/extensions.go | 109 ---- pkg/client/unversioned/flags.go | 31 - pkg/client/unversioned/flags_test.go | 79 --- .../unversioned/horizontalpodautoscaler.go | 103 ---- .../horizontalpodautoscaler_test.go | 173 ------ .../unversioned/import_known_versions.go | 42 -- pkg/client/unversioned/ingress.go | 100 ---- pkg/client/unversioned/ingress_test.go | 236 -------- pkg/client/unversioned/jobs.go | 167 ------ pkg/client/unversioned/jobs_test.go | 269 --------- pkg/client/unversioned/limit_ranges.go | 94 --- pkg/client/unversioned/limit_ranges_test.go | 185 ------ pkg/client/unversioned/namespaces.go | 116 ---- pkg/client/unversioned/namespaces_test.go | 185 ------ pkg/client/unversioned/network_policys.go | 92 --- pkg/client/unversioned/nodes.go | 111 ---- pkg/client/unversioned/nodes_test.go | 174 ------ .../unversioned/persistentvolume_test.go | 191 ------- .../unversioned/persistentvolumeclaim.go | 99 ---- .../unversioned/persistentvolumeclaim_test.go | 208 ------- pkg/client/unversioned/persistentvolumes.go | 93 --- pkg/client/unversioned/pet_sets.go | 100 ---- pkg/client/unversioned/pet_sets_test.go | 165 ------ .../unversioned/pod_disruption_budgets.go | 100 ---- pkg/client/unversioned/pod_templates.go | 94 --- pkg/client/unversioned/pod_templates_test.go | 147 ----- pkg/client/unversioned/pods.go | 115 ---- pkg/client/unversioned/pods_test.go | 227 -------- pkg/client/unversioned/podsecuritypolicy.go | 111 ---- .../unversioned/podsecuritypolicy_test.go | 137 ----- pkg/client/unversioned/policy.go | 55 -- pkg/client/unversioned/rbac.go | 73 --- pkg/client/unversioned/replica_sets.go | 100 ---- pkg/client/unversioned/replica_sets_test.go | 193 ------- .../unversioned/replication_controllers.go | 99 ---- .../replication_controllers_test.go | 200 ------- pkg/client/unversioned/resource_quotas.go | 102 ---- .../unversioned/resource_quotas_test.go | 204 ------- pkg/client/unversioned/rolebindings.go | 95 ---- pkg/client/unversioned/roles.go | 95 ---- pkg/client/unversioned/scale.go | 77 --- pkg/client/unversioned/scheduledjobs.go | 103 ---- pkg/client/unversioned/scheduledjobs_test.go | 277 --------- pkg/client/unversioned/secrets.go | 120 ---- pkg/client/unversioned/service_accounts.go | 120 ---- pkg/client/unversioned/services.go | 121 ---- pkg/client/unversioned/services_test.go | 239 -------- pkg/client/unversioned/storage.go | 77 --- pkg/client/unversioned/storageclasses.go | 87 --- pkg/client/unversioned/storageclasses_test.go | 147 ----- pkg/client/unversioned/subjectaccessreview.go | 45 -- pkg/client/unversioned/testclient/BUILD | 102 ---- pkg/client/unversioned/testclient/actions.go | 446 --------------- .../testclient/fake_certificates.go | 107 ---- .../testclient/fake_clusterrolebindings.go | 73 --- .../testclient/fake_clusterroles.go | 73 --- .../testclient/fake_componentstatuses.go | 44 -- .../unversioned/testclient/fake_configmaps.go | 78 --- .../testclient/fake_daemon_sets.go | 83 --- .../testclient/fake_deployments.go | 109 ---- .../unversioned/testclient/fake_endpoints.go | 74 --- .../unversioned/testclient/fake_events.go | 151 ----- .../fake_horizontal_pod_autoscalers.go | 93 --- .../unversioned/testclient/fake_ingress.go | 84 --- .../unversioned/testclient/fake_jobs.go | 147 ----- .../testclient/fake_limit_ranges.go | 74 --- .../unversioned/testclient/fake_namespaces.go | 103 ---- .../testclient/fake_network_policies.go | 75 --- .../unversioned/testclient/fake_nodes.go | 93 --- .../fake_persistent_volume_claims.go | 81 --- .../testclient/fake_persistent_volumes.go | 86 --- .../unversioned/testclient/fake_petsets.go | 83 --- .../testclient/fake_pod_templates.go | 74 --- .../unversioned/testclient/fake_pods.go | 117 ---- .../testclient/fake_podsecuritypolicy.go | 73 --- .../testclient/fake_replica_sets.go | 83 --- .../fake_replication_controllers.go | 82 --- .../testclient/fake_resource_quotas.go | 83 --- .../testclient/fake_rolebindings.go | 74 --- .../unversioned/testclient/fake_roles.go | 74 --- .../unversioned/testclient/fake_scales.go | 52 -- .../testclient/fake_scheduledjobs.go | 84 --- .../unversioned/testclient/fake_secrets.go | 74 --- .../testclient/fake_service_accounts.go | 74 --- .../unversioned/testclient/fake_services.go | 88 --- .../testclient/fake_storage_classes.go | 74 --- .../testclient/fake_subjectaccessreviews.go | 36 -- .../unversioned/testclient/fake_test.go | 39 -- .../testclient/fake_thirdpartyresources.go | 82 --- .../testclient/fake_tokenreviews.go | 35 -- pkg/client/unversioned/testclient/fixture.go | 313 ---------- .../testclient/simple/simple_testclient.go | 32 +- .../unversioned/testclient/testclient.go | 533 ------------------ .../unversioned/testclient/testclient_test.go | 75 --- pkg/client/unversioned/thirdpartyresources.go | 98 ---- .../unversioned/thirdpartyresources_test.go | 177 ------ pkg/client/unversioned/tokenreviews.go | 49 -- 121 files changed, 2 insertions(+), 14201 deletions(-) delete mode 100644 pkg/client/unversioned/apps.go delete mode 100644 pkg/client/unversioned/authentication.go delete mode 100644 pkg/client/unversioned/authorization.go delete mode 100644 pkg/client/unversioned/autoscaling.go delete mode 100644 pkg/client/unversioned/batch.go delete mode 100644 pkg/client/unversioned/certificates.go delete mode 100644 pkg/client/unversioned/certificatesigningrequests.go delete mode 100644 pkg/client/unversioned/client.go delete mode 100644 pkg/client/unversioned/clusterrolebindings.go delete mode 100644 pkg/client/unversioned/clusterroles.go delete mode 100644 pkg/client/unversioned/componentstatuses.go delete mode 100644 pkg/client/unversioned/configmap.go delete mode 100644 pkg/client/unversioned/containerinfo.go delete mode 100644 pkg/client/unversioned/containerinfo_test.go delete mode 100644 pkg/client/unversioned/daemon_sets.go delete mode 100644 pkg/client/unversioned/daemon_sets_test.go delete mode 100644 pkg/client/unversioned/deployment.go delete mode 100644 pkg/client/unversioned/deployment_test.go delete mode 100644 pkg/client/unversioned/doc.go delete mode 100644 pkg/client/unversioned/endpoints.go delete mode 100644 pkg/client/unversioned/endpoints_test.go delete mode 100644 pkg/client/unversioned/events.go delete mode 100644 pkg/client/unversioned/events_test.go delete mode 100644 pkg/client/unversioned/extensions.go delete mode 100644 pkg/client/unversioned/flags.go delete mode 100644 pkg/client/unversioned/flags_test.go delete mode 100644 pkg/client/unversioned/horizontalpodautoscaler.go delete mode 100644 pkg/client/unversioned/horizontalpodautoscaler_test.go delete mode 100644 pkg/client/unversioned/import_known_versions.go delete mode 100644 pkg/client/unversioned/ingress.go delete mode 100644 pkg/client/unversioned/ingress_test.go delete mode 100644 pkg/client/unversioned/jobs.go delete mode 100644 pkg/client/unversioned/jobs_test.go delete mode 100644 pkg/client/unversioned/limit_ranges.go delete mode 100644 pkg/client/unversioned/limit_ranges_test.go delete mode 100644 pkg/client/unversioned/namespaces.go delete mode 100644 pkg/client/unversioned/namespaces_test.go delete mode 100644 pkg/client/unversioned/network_policys.go delete mode 100644 pkg/client/unversioned/nodes.go delete mode 100644 pkg/client/unversioned/nodes_test.go delete mode 100644 pkg/client/unversioned/persistentvolume_test.go delete mode 100644 pkg/client/unversioned/persistentvolumeclaim.go delete mode 100644 pkg/client/unversioned/persistentvolumeclaim_test.go delete mode 100644 pkg/client/unversioned/persistentvolumes.go delete mode 100644 pkg/client/unversioned/pet_sets.go delete mode 100644 pkg/client/unversioned/pet_sets_test.go delete mode 100644 pkg/client/unversioned/pod_disruption_budgets.go delete mode 100644 pkg/client/unversioned/pod_templates.go delete mode 100644 pkg/client/unversioned/pod_templates_test.go delete mode 100644 pkg/client/unversioned/pods.go delete mode 100644 pkg/client/unversioned/pods_test.go delete mode 100644 pkg/client/unversioned/podsecuritypolicy.go delete mode 100644 pkg/client/unversioned/podsecuritypolicy_test.go delete mode 100644 pkg/client/unversioned/policy.go delete mode 100644 pkg/client/unversioned/rbac.go delete mode 100644 pkg/client/unversioned/replica_sets.go delete mode 100644 pkg/client/unversioned/replica_sets_test.go delete mode 100644 pkg/client/unversioned/replication_controllers.go delete mode 100644 pkg/client/unversioned/replication_controllers_test.go delete mode 100644 pkg/client/unversioned/resource_quotas.go delete mode 100644 pkg/client/unversioned/resource_quotas_test.go delete mode 100644 pkg/client/unversioned/rolebindings.go delete mode 100644 pkg/client/unversioned/roles.go delete mode 100644 pkg/client/unversioned/scale.go delete mode 100644 pkg/client/unversioned/scheduledjobs.go delete mode 100644 pkg/client/unversioned/scheduledjobs_test.go delete mode 100644 pkg/client/unversioned/secrets.go delete mode 100644 pkg/client/unversioned/service_accounts.go delete mode 100644 pkg/client/unversioned/services.go delete mode 100644 pkg/client/unversioned/services_test.go delete mode 100644 pkg/client/unversioned/storage.go delete mode 100644 pkg/client/unversioned/storageclasses.go delete mode 100644 pkg/client/unversioned/storageclasses_test.go delete mode 100644 pkg/client/unversioned/subjectaccessreview.go delete mode 100644 pkg/client/unversioned/testclient/BUILD delete mode 100644 pkg/client/unversioned/testclient/actions.go delete mode 100644 pkg/client/unversioned/testclient/fake_certificates.go delete mode 100644 pkg/client/unversioned/testclient/fake_clusterrolebindings.go delete mode 100644 pkg/client/unversioned/testclient/fake_clusterroles.go delete mode 100644 pkg/client/unversioned/testclient/fake_componentstatuses.go delete mode 100644 pkg/client/unversioned/testclient/fake_configmaps.go delete mode 100644 pkg/client/unversioned/testclient/fake_daemon_sets.go delete mode 100644 pkg/client/unversioned/testclient/fake_deployments.go delete mode 100644 pkg/client/unversioned/testclient/fake_endpoints.go delete mode 100644 pkg/client/unversioned/testclient/fake_events.go delete mode 100644 pkg/client/unversioned/testclient/fake_horizontal_pod_autoscalers.go delete mode 100644 pkg/client/unversioned/testclient/fake_ingress.go delete mode 100644 pkg/client/unversioned/testclient/fake_jobs.go delete mode 100644 pkg/client/unversioned/testclient/fake_limit_ranges.go delete mode 100644 pkg/client/unversioned/testclient/fake_namespaces.go delete mode 100644 pkg/client/unversioned/testclient/fake_network_policies.go delete mode 100644 pkg/client/unversioned/testclient/fake_nodes.go delete mode 100644 pkg/client/unversioned/testclient/fake_persistent_volume_claims.go delete mode 100644 pkg/client/unversioned/testclient/fake_persistent_volumes.go delete mode 100644 pkg/client/unversioned/testclient/fake_petsets.go delete mode 100644 pkg/client/unversioned/testclient/fake_pod_templates.go delete mode 100644 pkg/client/unversioned/testclient/fake_pods.go delete mode 100644 pkg/client/unversioned/testclient/fake_podsecuritypolicy.go delete mode 100644 pkg/client/unversioned/testclient/fake_replica_sets.go delete mode 100644 pkg/client/unversioned/testclient/fake_replication_controllers.go delete mode 100644 pkg/client/unversioned/testclient/fake_resource_quotas.go delete mode 100644 pkg/client/unversioned/testclient/fake_rolebindings.go delete mode 100644 pkg/client/unversioned/testclient/fake_roles.go delete mode 100644 pkg/client/unversioned/testclient/fake_scales.go delete mode 100644 pkg/client/unversioned/testclient/fake_scheduledjobs.go delete mode 100644 pkg/client/unversioned/testclient/fake_secrets.go delete mode 100644 pkg/client/unversioned/testclient/fake_service_accounts.go delete mode 100644 pkg/client/unversioned/testclient/fake_services.go delete mode 100644 pkg/client/unversioned/testclient/fake_storage_classes.go delete mode 100644 pkg/client/unversioned/testclient/fake_subjectaccessreviews.go delete mode 100644 pkg/client/unversioned/testclient/fake_test.go delete mode 100644 pkg/client/unversioned/testclient/fake_thirdpartyresources.go delete mode 100644 pkg/client/unversioned/testclient/fake_tokenreviews.go delete mode 100644 pkg/client/unversioned/testclient/fixture.go delete mode 100644 pkg/client/unversioned/testclient/testclient.go delete mode 100644 pkg/client/unversioned/testclient/testclient_test.go delete mode 100644 pkg/client/unversioned/thirdpartyresources.go delete mode 100644 pkg/client/unversioned/thirdpartyresources_test.go delete mode 100644 pkg/client/unversioned/tokenreviews.go diff --git a/hack/.linted_packages b/hack/.linted_packages index f85743ce176d7..51b3a862067a2 100644 --- a/hack/.linted_packages +++ b/hack/.linted_packages @@ -87,6 +87,7 @@ pkg/auth/authorizer/union pkg/client/metrics pkg/client/metrics/prometheus pkg/client/testing/core +pkg/client/typed/discovery pkg/client/unversioned pkg/client/unversioned/adapters/internalclientset pkg/client/unversioned/auth diff --git a/pkg/client/unversioned/apps.go b/pkg/client/unversioned/apps.go deleted file mode 100644 index 413c2a44910aa..0000000000000 --- a/pkg/client/unversioned/apps.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/apis/apps" - "k8s.io/kubernetes/pkg/client/restclient" -) - -type AppsInterface interface { - PetSetNamespacer -} - -// AppsClient is used to interact with Kubernetes batch features. -type AppsClient struct { - *restclient.RESTClient -} - -func (c *AppsClient) PetSets(namespace string) PetSetInterface { - return newPetSet(c, namespace) -} - -func NewApps(c *restclient.Config) (*AppsClient, error) { - config := *c - if err := setGroupDefaults(apps.GroupName, &config); err != nil { - return nil, err - } - client, err := restclient.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &AppsClient{client}, nil -} - -func NewAppsOrDie(c *restclient.Config) *AppsClient { - client, err := NewApps(c) - if err != nil { - panic(err) - } - return client -} diff --git a/pkg/client/unversioned/authentication.go b/pkg/client/unversioned/authentication.go deleted file mode 100644 index 6ac7f949fe38d..0000000000000 --- a/pkg/client/unversioned/authentication.go +++ /dev/null @@ -1,77 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apimachinery/registered" - "k8s.io/kubernetes/pkg/apis/authentication" - "k8s.io/kubernetes/pkg/client/restclient" -) - -type AuthenticationInterface interface { - TokenReviewsInterface -} - -// AuthenticationClient is used to interact with Kubernetes authentication features. -type AuthenticationClient struct { - *restclient.RESTClient -} - -func (c *AuthenticationClient) TokenReviews() TokenReviewInterface { - return newTokenReviews(c) -} - -func NewAuthentication(c *restclient.Config) (*AuthenticationClient, error) { - config := *c - if err := setAuthenticationDefaults(&config); err != nil { - return nil, err - } - client, err := restclient.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &AuthenticationClient{client}, nil -} - -func NewAuthenticationOrDie(c *restclient.Config) *AuthenticationClient { - client, err := NewAuthentication(c) - if err != nil { - panic(err) - } - return client -} - -func setAuthenticationDefaults(config *restclient.Config) error { - // if authentication group is not registered, return an error - g, err := registered.Group(authentication.GroupName) - if err != nil { - return err - } - config.APIPath = defaultAPIPath - if config.UserAgent == "" { - config.UserAgent = restclient.DefaultKubernetesUserAgent() - } - // TODO: Unconditionally set the config.Version, until we fix the config. - //if config.Version == "" { - copyGroupVersion := g.GroupVersion - config.GroupVersion = ©GroupVersion - //} - - config.NegotiatedSerializer = api.Codecs - return nil -} diff --git a/pkg/client/unversioned/authorization.go b/pkg/client/unversioned/authorization.go deleted file mode 100644 index beba40dca7cd1..0000000000000 --- a/pkg/client/unversioned/authorization.go +++ /dev/null @@ -1,77 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apimachinery/registered" - "k8s.io/kubernetes/pkg/apis/authorization" - "k8s.io/kubernetes/pkg/client/restclient" -) - -type AuthorizationInterface interface { - SubjectAccessReviewsInterface -} - -// AuthorizationClient is used to interact with Kubernetes authorization features. -type AuthorizationClient struct { - *restclient.RESTClient -} - -func (c *AuthorizationClient) SubjectAccessReviews() SubjectAccessReviewInterface { - return newSubjectAccessReviews(c) -} - -func NewAuthorization(c *restclient.Config) (*AuthorizationClient, error) { - config := *c - if err := setAuthorizationDefaults(&config); err != nil { - return nil, err - } - client, err := restclient.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &AuthorizationClient{client}, nil -} - -func NewAuthorizationOrDie(c *restclient.Config) *AuthorizationClient { - client, err := NewAuthorization(c) - if err != nil { - panic(err) - } - return client -} - -func setAuthorizationDefaults(config *restclient.Config) error { - // if authorization group is not registered, return an error - g, err := registered.Group(authorization.GroupName) - if err != nil { - return err - } - config.APIPath = defaultAPIPath - if config.UserAgent == "" { - config.UserAgent = restclient.DefaultKubernetesUserAgent() - } - // TODO: Unconditionally set the config.Version, until we fix the config. - //if config.Version == "" { - copyGroupVersion := g.GroupVersion - config.GroupVersion = ©GroupVersion - //} - - config.NegotiatedSerializer = api.Codecs - return nil -} diff --git a/pkg/client/unversioned/autoscaling.go b/pkg/client/unversioned/autoscaling.go deleted file mode 100644 index e53d23d8b229e..0000000000000 --- a/pkg/client/unversioned/autoscaling.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/apis/autoscaling" - "k8s.io/kubernetes/pkg/client/restclient" -) - -type AutoscalingInterface interface { - HorizontalPodAutoscalersNamespacer -} - -// AutoscalingClient is used to interact with Kubernetes autoscaling features. -type AutoscalingClient struct { - *restclient.RESTClient -} - -func (c *AutoscalingClient) HorizontalPodAutoscalers(namespace string) HorizontalPodAutoscalerInterface { - return newHorizontalPodAutoscalers(c, namespace) -} - -func NewAutoscaling(c *restclient.Config) (*AutoscalingClient, error) { - config := *c - if err := setGroupDefaults(autoscaling.GroupName, &config); err != nil { - return nil, err - } - client, err := restclient.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &AutoscalingClient{client}, nil -} - -func NewAutoscalingOrDie(c *restclient.Config) *AutoscalingClient { - client, err := NewAutoscaling(c) - if err != nil { - panic(err) - } - return client -} diff --git a/pkg/client/unversioned/batch.go b/pkg/client/unversioned/batch.go deleted file mode 100644 index 0957424a6477a..0000000000000 --- a/pkg/client/unversioned/batch.go +++ /dev/null @@ -1,60 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/apis/batch" - "k8s.io/kubernetes/pkg/client/restclient" -) - -type BatchInterface interface { - JobsNamespacer - ScheduledJobsNamespacer -} - -// BatchClient is used to interact with Kubernetes batch features. -type BatchClient struct { - *restclient.RESTClient -} - -func (c *BatchClient) Jobs(namespace string) JobInterface { - return newJobsV1(c, namespace) -} - -func (c *BatchClient) ScheduledJobs(namespace string) ScheduledJobInterface { - return newScheduledJobs(c, namespace) -} - -func NewBatch(c *restclient.Config) (*BatchClient, error) { - config := *c - if err := setGroupDefaults(batch.GroupName, &config); err != nil { - return nil, err - } - client, err := restclient.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &BatchClient{client}, nil -} - -func NewBatchOrDie(c *restclient.Config) *BatchClient { - client, err := NewBatch(c) - if err != nil { - panic(err) - } - return client -} diff --git a/pkg/client/unversioned/certificates.go b/pkg/client/unversioned/certificates.go deleted file mode 100644 index 273b957f5ea31..0000000000000 --- a/pkg/client/unversioned/certificates.go +++ /dev/null @@ -1,69 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/apis/certificates" - "k8s.io/kubernetes/pkg/client/restclient" -) - -// Interface holds the methods for clients of Kubernetes to allow mock testing. -type CertificatesInterface interface { - CertificateSigningRequests() CertificateSigningRequestInterface -} - -type CertificatesClient struct { - *restclient.RESTClient -} - -func (c *CertificatesClient) CertificateSigningRequests() CertificateSigningRequestInterface { - return newCertificateSigningRequests(c) -} - -// NewCertificates creates a new CertificatesClient for the given config. -func NewCertificates(c *restclient.Config) (*CertificatesClient, error) { - config := *c - if err := setCertificatesDefaults(&config); err != nil { - return nil, err - } - client, err := restclient.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &CertificatesClient{client}, nil -} - -// NewCertificatesOrDie creates a new CertificatesClient for the given config and -// panics if there is an error in the config. -func NewCertificatesOrDie(c *restclient.Config) *CertificatesClient { - client, err := NewCertificates(c) - if err != nil { - panic(err) - } - return client -} - -func setCertificatesDefaults(config *restclient.Config) error { - setGroupDefaults(certificates.GroupName, config) - if config.QPS == 0 { - config.QPS = 5 - } - if config.Burst == 0 { - config.Burst = 10 - } - return nil -} diff --git a/pkg/client/unversioned/certificatesigningrequests.go b/pkg/client/unversioned/certificatesigningrequests.go deleted file mode 100644 index f3ce09fc387b3..0000000000000 --- a/pkg/client/unversioned/certificatesigningrequests.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/certificates" - "k8s.io/kubernetes/pkg/watch" -) - -// CertificateSigningRequestInterface has methods to work with CertificateSigningRequest resources. -type CertificateSigningRequestInterface interface { - List(opts api.ListOptions) (*certificates.CertificateSigningRequestList, error) - Get(name string) (*certificates.CertificateSigningRequest, error) - Delete(name string, options *api.DeleteOptions) error - Create(certificateSigningRequest *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) - Update(certificateSigningRequest *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) - UpdateStatus(certificateSigningRequest *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) - UpdateApproval(certificateSigningRequest *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// certificateSigningRequests implements CertificateSigningRequestsNamespacer interface -type certificateSigningRequests struct { - client *CertificatesClient -} - -// newCertificateSigningRequests returns a certificateSigningRequests -func newCertificateSigningRequests(c *CertificatesClient) *certificateSigningRequests { - return &certificateSigningRequests{ - client: c, - } -} - -// List takes label and field selectors, and returns the list of certificateSigningRequests that match those selectors. -func (c *certificateSigningRequests) List(opts api.ListOptions) (result *certificates.CertificateSigningRequestList, err error) { - result = &certificates.CertificateSigningRequestList{} - err = c.client.Get().Resource("certificatesigningrequests").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get takes the name of the certificateSigningRequest, and returns the corresponding CertificateSigningRequest object, and an error if it occurs -func (c *certificateSigningRequests) Get(name string) (result *certificates.CertificateSigningRequest, err error) { - result = &certificates.CertificateSigningRequest{} - err = c.client.Get().Resource("certificatesigningrequests").Name(name).Do().Into(result) - return -} - -// Delete takes the name of the certificateSigningRequest and deletes it. Returns an error if one occurs. -func (c *certificateSigningRequests) Delete(name string, options *api.DeleteOptions) error { - return c.client.Delete().Resource("certificatesigningrequests").Name(name).Body(options).Do().Error() -} - -// Create takes the representation of a certificateSigningRequest and creates it. Returns the server's representation of the certificateSigningRequest, and an error, if it occurs. -func (c *certificateSigningRequests) Create(certificateSigningRequest *certificates.CertificateSigningRequest) (result *certificates.CertificateSigningRequest, err error) { - result = &certificates.CertificateSigningRequest{} - err = c.client.Post().Resource("certificatesigningrequests").Body(certificateSigningRequest).Do().Into(result) - return -} - -// Update takes the representation of a certificateSigningRequest and updates it. Returns the server's representation of the certificateSigningRequest, and an error, if it occurs. -func (c *certificateSigningRequests) Update(certificateSigningRequest *certificates.CertificateSigningRequest) (result *certificates.CertificateSigningRequest, err error) { - result = &certificates.CertificateSigningRequest{} - err = c.client.Put().Resource("certificatesigningrequests").Name(certificateSigningRequest.Name).Body(certificateSigningRequest).Do().Into(result) - return -} - -// UpdateStatus takes the representation of a certificateSigningRequest and updates it. Returns the server's representation of the certificateSigningRequest, and an error, if it occurs. -func (c *certificateSigningRequests) UpdateStatus(certificateSigningRequest *certificates.CertificateSigningRequest) (result *certificates.CertificateSigningRequest, err error) { - result = &certificates.CertificateSigningRequest{} - err = c.client.Put().Resource("certificatesigningrequests").Name(certificateSigningRequest.Name).SubResource("status").Body(certificateSigningRequest).Do().Into(result) - return -} - -// UpdateApproval takes the representation of a certificateSigningRequest and updates it. Returns the server's representation of the certificateSigningRequest, and an error, if it occurs. -func (c *certificateSigningRequests) UpdateApproval(certificateSigningRequest *certificates.CertificateSigningRequest) (result *certificates.CertificateSigningRequest, err error) { - result = &certificates.CertificateSigningRequest{} - err = c.client.Put().Resource("certificatesigningrequests").Name(certificateSigningRequest.Name).SubResource("approval").Body(certificateSigningRequest).Do().Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested certificateSigningRequests. -func (c *certificateSigningRequests) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.client.Get(). - Prefix("watch"). - Namespace(api.NamespaceAll). - Resource("certificatesigningrequests"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/client.go b/pkg/client/unversioned/client.go deleted file mode 100644 index 0e23248d4d2b0..0000000000000 --- a/pkg/client/unversioned/client.go +++ /dev/null @@ -1,202 +0,0 @@ -/* -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 unversioned - -import ( - "net" - "net/url" - "strings" - - "k8s.io/kubernetes/pkg/client/restclient" - "k8s.io/kubernetes/pkg/client/typed/discovery" -) - -// Interface holds the methods for clients of Kubernetes, -// an interface to allow mock testing. -type Interface interface { - PodsNamespacer - PodTemplatesNamespacer - ReplicationControllersNamespacer - ServicesNamespacer - EndpointsNamespacer - NodesInterface - EventNamespacer - LimitRangesNamespacer - ResourceQuotasNamespacer - ServiceAccountsNamespacer - SecretsNamespacer - NamespacesInterface - PersistentVolumesInterface - PersistentVolumeClaimsNamespacer - ComponentStatusesInterface - ConfigMapsNamespacer - Apps() AppsInterface - Authorization() AuthorizationInterface - Autoscaling() AutoscalingInterface - Authentication() AuthenticationInterface - Batch() BatchInterface - Extensions() ExtensionsInterface - Rbac() RbacInterface - Discovery() discovery.DiscoveryInterface - Certificates() CertificatesInterface - Storage() StorageInterface -} - -func (c *Client) ReplicationControllers(namespace string) ReplicationControllerInterface { - return newReplicationControllers(c, namespace) -} - -func (c *Client) Nodes() NodeInterface { - return newNodes(c) -} - -func (c *Client) Events(namespace string) EventInterface { - return newEvents(c, namespace) -} - -func (c *Client) Endpoints(namespace string) EndpointsInterface { - return newEndpoints(c, namespace) -} - -func (c *Client) Pods(namespace string) PodInterface { - return newPods(c, namespace) -} - -func (c *Client) PodTemplates(namespace string) PodTemplateInterface { - return newPodTemplates(c, namespace) -} - -func (c *Client) Services(namespace string) ServiceInterface { - return newServices(c, namespace) -} -func (c *Client) LimitRanges(namespace string) LimitRangeInterface { - return newLimitRanges(c, namespace) -} - -func (c *Client) ResourceQuotas(namespace string) ResourceQuotaInterface { - return newResourceQuotas(c, namespace) -} - -func (c *Client) ServiceAccounts(namespace string) ServiceAccountsInterface { - return newServiceAccounts(c, namespace) -} - -func (c *Client) Secrets(namespace string) SecretsInterface { - return newSecrets(c, namespace) -} - -func (c *Client) Namespaces() NamespaceInterface { - return newNamespaces(c) -} - -func (c *Client) PersistentVolumes() PersistentVolumeInterface { - return newPersistentVolumes(c) -} - -func (c *Client) PersistentVolumeClaims(namespace string) PersistentVolumeClaimInterface { - return newPersistentVolumeClaims(c, namespace) -} - -func (c *Client) ComponentStatuses() ComponentStatusInterface { - return newComponentStatuses(c) -} - -func (c *Client) ConfigMaps(namespace string) ConfigMapsInterface { - return newConfigMaps(c, namespace) -} - -// Client is the implementation of a Kubernetes client. -type Client struct { - *restclient.RESTClient - *AuthorizationClient - *AutoscalingClient - *AuthenticationClient - *BatchClient - *ExtensionsClient - *AppsClient - *PolicyClient - *RbacClient - *discovery.DiscoveryClient - *CertificatesClient - *StorageClient -} - -// IsTimeout tests if this is a timeout error in the underlying transport. -// This is unbelievably ugly. -// See: http://stackoverflow.com/questions/23494950/specifically-check-for-timeout-error for details -func IsTimeout(err error) bool { - if err == nil { - return false - } - switch err := err.(type) { - case *url.Error: - if err, ok := err.Err.(net.Error); ok { - return err.Timeout() - } - case net.Error: - return err.Timeout() - } - - if strings.Contains(err.Error(), "use of closed network connection") { - return true - } - return false -} - -func (c *Client) Authorization() AuthorizationInterface { - return c.AuthorizationClient -} - -func (c *Client) Autoscaling() AutoscalingInterface { - return c.AutoscalingClient -} - -func (c *Client) Authentication() AuthenticationInterface { - return c.AuthenticationClient -} - -func (c *Client) Batch() BatchInterface { - return c.BatchClient -} - -func (c *Client) Extensions() ExtensionsInterface { - return c.ExtensionsClient -} - -func (c *Client) Apps() AppsInterface { - return c.AppsClient -} - -func (c *Client) Rbac() RbacInterface { - return c.RbacClient -} - -func (c *Client) Policy() PolicyInterface { - return c.PolicyClient -} - -func (c *Client) Discovery() discovery.DiscoveryInterface { - return c.DiscoveryClient -} - -func (c *Client) Certificates() CertificatesInterface { - return c.CertificatesClient -} - -func (c *Client) Storage() StorageInterface { - return c.StorageClient -} diff --git a/pkg/client/unversioned/clusterrolebindings.go b/pkg/client/unversioned/clusterrolebindings.go deleted file mode 100644 index fa9cad97d3e51..0000000000000 --- a/pkg/client/unversioned/clusterrolebindings.go +++ /dev/null @@ -1,92 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/rbac" - "k8s.io/kubernetes/pkg/watch" -) - -// ClusterRoleBindings has methods to work with ClusterRoleBinding resources in a namespace -type ClusterRoleBindings interface { - ClusterRoleBindings() ClusterRoleBindingInterface -} - -// ClusterRoleBindingInterface has methods to work with ClusterRoleBinding resources. -type ClusterRoleBindingInterface interface { - List(opts api.ListOptions) (*rbac.ClusterRoleBindingList, error) - Get(name string) (*rbac.ClusterRoleBinding, error) - Delete(name string, options *api.DeleteOptions) error - Create(clusterRoleBinding *rbac.ClusterRoleBinding) (*rbac.ClusterRoleBinding, error) - Update(clusterRoleBinding *rbac.ClusterRoleBinding) (*rbac.ClusterRoleBinding, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// clusterRoleBindings implements ClusterRoleBindingsNamespacer interface -type clusterRoleBindings struct { - client *RbacClient -} - -// newClusterRoleBindings returns a clusterRoleBindings -func newClusterRoleBindings(c *RbacClient) *clusterRoleBindings { - return &clusterRoleBindings{ - client: c, - } -} - -// List takes label and field selectors, and returns the list of clusterRoleBindings that match those selectors. -func (c *clusterRoleBindings) List(opts api.ListOptions) (result *rbac.ClusterRoleBindingList, err error) { - result = &rbac.ClusterRoleBindingList{} - err = c.client.Get().Resource("clusterrolebindings").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get takes the name of the clusterRoleBinding, and returns the corresponding ClusterRoleBinding object, and an error if it occurs -func (c *clusterRoleBindings) Get(name string) (result *rbac.ClusterRoleBinding, err error) { - result = &rbac.ClusterRoleBinding{} - err = c.client.Get().Resource("clusterrolebindings").Name(name).Do().Into(result) - return -} - -// Delete takes the name of the clusterRoleBinding and deletes it. Returns an error if one occurs. -func (c *clusterRoleBindings) Delete(name string, options *api.DeleteOptions) error { - return c.client.Delete().Resource("clusterrolebindings").Name(name).Body(options).Do().Error() -} - -// Create takes the representation of a clusterRoleBinding and creates it. Returns the server's representation of the clusterRoleBinding, and an error, if it occurs. -func (c *clusterRoleBindings) Create(clusterRoleBinding *rbac.ClusterRoleBinding) (result *rbac.ClusterRoleBinding, err error) { - result = &rbac.ClusterRoleBinding{} - err = c.client.Post().Resource("clusterrolebindings").Body(clusterRoleBinding).Do().Into(result) - return -} - -// Update takes the representation of a clusterRoleBinding and updates it. Returns the server's representation of the clusterRoleBinding, and an error, if it occurs. -func (c *clusterRoleBindings) Update(clusterRoleBinding *rbac.ClusterRoleBinding) (result *rbac.ClusterRoleBinding, err error) { - result = &rbac.ClusterRoleBinding{} - err = c.client.Put().Resource("clusterrolebindings").Name(clusterRoleBinding.Name).Body(clusterRoleBinding).Do().Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested clusterRoleBindings. -func (c *clusterRoleBindings) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.client.Get(). - Prefix("watch"). - Resource("clusterrolebindings"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/clusterroles.go b/pkg/client/unversioned/clusterroles.go deleted file mode 100644 index 165271ab504e5..0000000000000 --- a/pkg/client/unversioned/clusterroles.go +++ /dev/null @@ -1,92 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/rbac" - "k8s.io/kubernetes/pkg/watch" -) - -// ClusterRoles has methods to work with ClusterRole resources in a namespace -type ClusterRoles interface { - ClusterRoles() ClusterRoleInterface -} - -// ClusterRoleInterface has methods to work with ClusterRole resources. -type ClusterRoleInterface interface { - List(opts api.ListOptions) (*rbac.ClusterRoleList, error) - Get(name string) (*rbac.ClusterRole, error) - Delete(name string, options *api.DeleteOptions) error - Create(clusterRole *rbac.ClusterRole) (*rbac.ClusterRole, error) - Update(clusterRole *rbac.ClusterRole) (*rbac.ClusterRole, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// clusterRoles implements ClusterRolesNamespacer interface -type clusterRoles struct { - client *RbacClient -} - -// newClusterRoles returns a clusterRoles -func newClusterRoles(c *RbacClient) *clusterRoles { - return &clusterRoles{ - client: c, - } -} - -// List takes label and field selectors, and returns the list of clusterRoles that match those selectors. -func (c *clusterRoles) List(opts api.ListOptions) (result *rbac.ClusterRoleList, err error) { - result = &rbac.ClusterRoleList{} - err = c.client.Get().Resource("clusterroles").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get takes the name of the clusterRole, and returns the corresponding ClusterRole object, and an error if it occurs -func (c *clusterRoles) Get(name string) (result *rbac.ClusterRole, err error) { - result = &rbac.ClusterRole{} - err = c.client.Get().Resource("clusterroles").Name(name).Do().Into(result) - return -} - -// Delete takes the name of the clusterRole and deletes it. Returns an error if one occurs. -func (c *clusterRoles) Delete(name string, options *api.DeleteOptions) error { - return c.client.Delete().Resource("clusterroles").Name(name).Body(options).Do().Error() -} - -// Create takes the representation of a clusterRole and creates it. Returns the server's representation of the clusterRole, and an error, if it occurs. -func (c *clusterRoles) Create(clusterRole *rbac.ClusterRole) (result *rbac.ClusterRole, err error) { - result = &rbac.ClusterRole{} - err = c.client.Post().Resource("clusterroles").Body(clusterRole).Do().Into(result) - return -} - -// Update takes the representation of a clusterRole and updates it. Returns the server's representation of the clusterRole, and an error, if it occurs. -func (c *clusterRoles) Update(clusterRole *rbac.ClusterRole) (result *rbac.ClusterRole, err error) { - result = &rbac.ClusterRole{} - err = c.client.Put().Resource("clusterroles").Name(clusterRole.Name).Body(clusterRole).Do().Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested clusterRoles. -func (c *clusterRoles) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.client.Get(). - Prefix("watch"). - Resource("clusterroles"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/componentstatuses.go b/pkg/client/unversioned/componentstatuses.go deleted file mode 100644 index aca996b2b0007..0000000000000 --- a/pkg/client/unversioned/componentstatuses.go +++ /dev/null @@ -1,60 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" -) - -type ComponentStatusesInterface interface { - ComponentStatuses() ComponentStatusInterface -} - -// ComponentStatusInterface contains methods to retrieve ComponentStatus -type ComponentStatusInterface interface { - List(opts api.ListOptions) (*api.ComponentStatusList, error) - Get(name string) (*api.ComponentStatus, error) - - // TODO: It'd be nice to have watch support at some point - //Watch(opts api.ListOptions) (watch.Interface, error) -} - -// componentStatuses implements ComponentStatusesInterface -type componentStatuses struct { - client *Client -} - -func newComponentStatuses(c *Client) *componentStatuses { - return &componentStatuses{c} -} - -func (c *componentStatuses) List(opts api.ListOptions) (result *api.ComponentStatusList, err error) { - result = &api.ComponentStatusList{} - err = c.client.Get(). - Resource("componentStatuses"). - VersionedParams(&opts, api.ParameterCodec). - Do(). - Into(result) - - return result, err -} - -func (c *componentStatuses) Get(name string) (result *api.ComponentStatus, err error) { - result = &api.ComponentStatus{} - err = c.client.Get().Resource("componentStatuses").Name(name).Do().Into(result) - return -} diff --git a/pkg/client/unversioned/configmap.go b/pkg/client/unversioned/configmap.go deleted file mode 100644 index c2f20354f4a06..0000000000000 --- a/pkg/client/unversioned/configmap.go +++ /dev/null @@ -1,122 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -const ( - ConfigMapResourceName string = "configmaps" -) - -type ConfigMapsNamespacer interface { - ConfigMaps(namespace string) ConfigMapsInterface -} - -type ConfigMapsInterface interface { - Get(string) (*api.ConfigMap, error) - List(opts api.ListOptions) (*api.ConfigMapList, error) - Create(*api.ConfigMap) (*api.ConfigMap, error) - Delete(string) error - Update(*api.ConfigMap) (*api.ConfigMap, error) - Watch(api.ListOptions) (watch.Interface, error) -} - -type ConfigMaps struct { - client *Client - namespace string -} - -// ConfigMaps should implement ConfigMapsInterface -var _ ConfigMapsInterface = &ConfigMaps{} - -func newConfigMaps(c *Client, ns string) *ConfigMaps { - return &ConfigMaps{ - client: c, - namespace: ns, - } -} - -func (c *ConfigMaps) Get(name string) (*api.ConfigMap, error) { - result := &api.ConfigMap{} - err := c.client.Get(). - Namespace(c.namespace). - Resource(ConfigMapResourceName). - Name(name). - Do(). - Into(result) - - return result, err -} - -func (c *ConfigMaps) List(opts api.ListOptions) (*api.ConfigMapList, error) { - result := &api.ConfigMapList{} - err := c.client.Get(). - Namespace(c.namespace). - Resource(ConfigMapResourceName). - VersionedParams(&opts, api.ParameterCodec). - Do(). - Into(result) - - return result, err -} - -func (c *ConfigMaps) Create(cfg *api.ConfigMap) (*api.ConfigMap, error) { - result := &api.ConfigMap{} - err := c.client.Post(). - Namespace(c.namespace). - Resource(ConfigMapResourceName). - Body(cfg). - Do(). - Into(result) - - return result, err -} - -func (c *ConfigMaps) Delete(name string) error { - return c.client.Delete(). - Namespace(c.namespace). - Resource(ConfigMapResourceName). - Name(name). - Do(). - Error() -} - -func (c *ConfigMaps) Update(cfg *api.ConfigMap) (*api.ConfigMap, error) { - result := &api.ConfigMap{} - - err := c.client.Put(). - Namespace(c.namespace). - Resource(ConfigMapResourceName). - Name(cfg.Name). - Body(cfg). - Do(). - Into(result) - - return result, err -} - -func (c *ConfigMaps) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.client.Get(). - Prefix("watch"). - Namespace(c.namespace). - Resource(ConfigMapResourceName). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/containerinfo.go b/pkg/client/unversioned/containerinfo.go deleted file mode 100644 index 2f9aae8ab3841..0000000000000 --- a/pkg/client/unversioned/containerinfo.go +++ /dev/null @@ -1,123 +0,0 @@ -/* -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 unversioned - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "net" - "net/http" - "strconv" - - cadvisorapi "github.com/google/cadvisor/info/v1" -) - -type ContainerInfoGetter interface { - // GetContainerInfo returns information about a container. - GetContainerInfo(host, podID, containerID string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) - // GetRootInfo returns information about the root container on a machine. - GetRootInfo(host string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) - // GetMachineInfo returns the machine's information like number of cores, memory capacity. - GetMachineInfo(host string) (*cadvisorapi.MachineInfo, error) -} - -type HTTPContainerInfoGetter struct { - Client *http.Client - Port int -} - -func (self *HTTPContainerInfoGetter) GetMachineInfo(host string) (*cadvisorapi.MachineInfo, error) { - request, err := http.NewRequest( - "GET", - fmt.Sprintf("http://%v/spec", - net.JoinHostPort(host, strconv.Itoa(self.Port)), - ), - nil, - ) - if err != nil { - return nil, err - } - - response, err := self.Client.Do(request) - if err != nil { - return nil, err - } - defer response.Body.Close() - if response.StatusCode != http.StatusOK { - return nil, fmt.Errorf("trying to get machine spec from %v; received status %v", - host, response.Status) - } - var minfo cadvisorapi.MachineInfo - err = json.NewDecoder(response.Body).Decode(&minfo) - if err != nil { - return nil, err - } - return &minfo, nil -} - -func (self *HTTPContainerInfoGetter) getContainerInfo(host, path string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) { - var body io.Reader - if req != nil { - content, err := json.Marshal(req) - if err != nil { - return nil, err - } - body = bytes.NewBuffer(content) - } - - request, err := http.NewRequest( - "GET", - fmt.Sprintf("http://%v/stats/%v", - net.JoinHostPort(host, strconv.Itoa(self.Port)), - path, - ), - body, - ) - if err != nil { - return nil, err - } - - response, err := self.Client.Do(request) - if err != nil { - return nil, err - } - defer response.Body.Close() - if response.StatusCode != http.StatusOK { - return nil, fmt.Errorf("trying to get info for %v from %v; received status %v", - path, host, response.Status) - } - var cinfo cadvisorapi.ContainerInfo - err = json.NewDecoder(response.Body).Decode(&cinfo) - if err != nil { - return nil, err - } - return &cinfo, nil -} - -func (self *HTTPContainerInfoGetter) GetContainerInfo(host, podID, containerID string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) { - return self.getContainerInfo( - host, - fmt.Sprintf("%v/%v", podID, containerID), - req, - ) -} - -func (self *HTTPContainerInfoGetter) GetRootInfo(host string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) { - return self.getContainerInfo(host, "", req) -} diff --git a/pkg/client/unversioned/containerinfo_test.go b/pkg/client/unversioned/containerinfo_test.go deleted file mode 100644 index 34ddd444e2dba..0000000000000 --- a/pkg/client/unversioned/containerinfo_test.go +++ /dev/null @@ -1,198 +0,0 @@ -/* -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 unversioned - -import ( - "encoding/json" - "net/http" - "net/http/httptest" - "net/url" - "path" - "reflect" - "strconv" - "strings" - "testing" - "time" - - cadvisorapi "github.com/google/cadvisor/info/v1" - cadvisorapitest "github.com/google/cadvisor/info/v1/test" -) - -func testHTTPContainerInfoGetter( - req *cadvisorapi.ContainerInfoRequest, - cinfo *cadvisorapi.ContainerInfo, - podID string, - containerID string, - status int, - t *testing.T, -) { - expectedPath := "/stats" - if len(podID) > 0 && len(containerID) > 0 { - expectedPath = path.Join(expectedPath, podID, containerID) - } - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if status != 0 { - w.WriteHeader(status) - } - if strings.TrimRight(r.URL.Path, "/") != strings.TrimRight(expectedPath, "/") { - t.Fatalf("Received request to an invalid path. Should be %v. got %v", - expectedPath, r.URL.Path) - } - - var receivedReq cadvisorapi.ContainerInfoRequest - err := json.NewDecoder(r.Body).Decode(&receivedReq) - if err != nil { - t.Fatal(err) - } - // Note: This will not make a deep copy of req. - // So changing req after Get*Info would be a race. - expectedReq := req - // Fill any empty fields with default value - if !expectedReq.Equals(receivedReq) { - t.Errorf("received wrong request") - } - err = json.NewEncoder(w).Encode(cinfo) - if err != nil { - t.Fatal(err) - } - })) - defer ts.Close() - hostURL, err := url.Parse(ts.URL) - if err != nil { - t.Fatal(err) - } - parts := strings.Split(hostURL.Host, ":") - - port, err := strconv.Atoi(parts[1]) - if err != nil { - t.Fatal(err) - } - - containerInfoGetter := &HTTPContainerInfoGetter{ - Client: http.DefaultClient, - Port: port, - } - - var receivedContainerInfo *cadvisorapi.ContainerInfo - if len(podID) > 0 && len(containerID) > 0 { - receivedContainerInfo, err = containerInfoGetter.GetContainerInfo(parts[0], podID, containerID, req) - } else { - receivedContainerInfo, err = containerInfoGetter.GetRootInfo(parts[0], req) - } - if status == 0 || status == http.StatusOK { - if err != nil { - t.Errorf("received unexpected error: %v", err) - } - - if !receivedContainerInfo.Eq(cinfo) { - t.Error("received unexpected container info") - } - } else { - if err == nil { - t.Error("did not receive expected error.") - } - } -} - -func TestHTTPContainerInfoGetterGetContainerInfoSuccessfully(t *testing.T) { - req := &cadvisorapi.ContainerInfoRequest{ - NumStats: 10, - } - cinfo := cadvisorapitest.GenerateRandomContainerInfo( - "dockerIDWhichWillNotBeChecked", // docker ID - 2, // Number of cores - req, - 1*time.Second, - ) - testHTTPContainerInfoGetter(req, cinfo, "somePodID", "containerNameInK8S", 0, t) -} - -func TestHTTPContainerInfoGetterGetRootInfoSuccessfully(t *testing.T) { - req := &cadvisorapi.ContainerInfoRequest{ - NumStats: 10, - } - cinfo := cadvisorapitest.GenerateRandomContainerInfo( - "dockerIDWhichWillNotBeChecked", // docker ID - 2, // Number of cores - req, - 1*time.Second, - ) - testHTTPContainerInfoGetter(req, cinfo, "", "", 0, t) -} - -func TestHTTPContainerInfoGetterGetContainerInfoWithError(t *testing.T) { - req := &cadvisorapi.ContainerInfoRequest{ - NumStats: 10, - } - cinfo := cadvisorapitest.GenerateRandomContainerInfo( - "dockerIDWhichWillNotBeChecked", // docker ID - 2, // Number of cores - req, - 1*time.Second, - ) - testHTTPContainerInfoGetter(req, cinfo, "somePodID", "containerNameInK8S", http.StatusNotFound, t) -} - -func TestHTTPContainerInfoGetterGetRootInfoWithError(t *testing.T) { - req := &cadvisorapi.ContainerInfoRequest{ - NumStats: 10, - } - cinfo := cadvisorapitest.GenerateRandomContainerInfo( - "dockerIDWhichWillNotBeChecked", // docker ID - 2, // Number of cores - req, - 1*time.Second, - ) - testHTTPContainerInfoGetter(req, cinfo, "", "", http.StatusNotFound, t) -} - -func TestHTTPGetMachineInfo(t *testing.T) { - mspec := &cadvisorapi.MachineInfo{ - NumCores: 4, - MemoryCapacity: 2048, - } - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - err := json.NewEncoder(w).Encode(mspec) - if err != nil { - t.Fatal(err) - } - })) - defer ts.Close() - hostURL, err := url.Parse(ts.URL) - if err != nil { - t.Fatal(err) - } - parts := strings.Split(hostURL.Host, ":") - - port, err := strconv.Atoi(parts[1]) - if err != nil { - t.Fatal(err) - } - - containerInfoGetter := &HTTPContainerInfoGetter{ - Client: http.DefaultClient, - Port: port, - } - - received, err := containerInfoGetter.GetMachineInfo(parts[0]) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(received, mspec) { - t.Errorf("received wrong machine spec") - } -} diff --git a/pkg/client/unversioned/daemon_sets.go b/pkg/client/unversioned/daemon_sets.go deleted file mode 100644 index 7ec9182f8aecd..0000000000000 --- a/pkg/client/unversioned/daemon_sets.go +++ /dev/null @@ -1,100 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/watch" -) - -// DaemonsSetsNamespacer has methods to work with DaemonSet resources in a namespace -type DaemonSetsNamespacer interface { - DaemonSets(namespace string) DaemonSetInterface -} - -type DaemonSetInterface interface { - List(opts api.ListOptions) (*extensions.DaemonSetList, error) - Get(name string) (*extensions.DaemonSet, error) - Create(ctrl *extensions.DaemonSet) (*extensions.DaemonSet, error) - Update(ctrl *extensions.DaemonSet) (*extensions.DaemonSet, error) - UpdateStatus(ctrl *extensions.DaemonSet) (*extensions.DaemonSet, error) - Delete(name string) error - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// daemonSets implements DaemonsSetsNamespacer interface -type daemonSets struct { - r *ExtensionsClient - ns string -} - -func newDaemonSets(c *ExtensionsClient, namespace string) *daemonSets { - return &daemonSets{c, namespace} -} - -// Ensure statically that daemonSets implements DaemonSetsInterface. -var _ DaemonSetInterface = &daemonSets{} - -func (c *daemonSets) List(opts api.ListOptions) (result *extensions.DaemonSetList, err error) { - result = &extensions.DaemonSetList{} - err = c.r.Get().Namespace(c.ns).Resource("daemonsets").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get returns information about a particular daemon set. -func (c *daemonSets) Get(name string) (result *extensions.DaemonSet, err error) { - result = &extensions.DaemonSet{} - err = c.r.Get().Namespace(c.ns).Resource("daemonsets").Name(name).Do().Into(result) - return -} - -// Create creates a new daemon set. -func (c *daemonSets) Create(daemon *extensions.DaemonSet) (result *extensions.DaemonSet, err error) { - result = &extensions.DaemonSet{} - err = c.r.Post().Namespace(c.ns).Resource("daemonsets").Body(daemon).Do().Into(result) - return -} - -// Update updates an existing daemon set. -func (c *daemonSets) Update(daemon *extensions.DaemonSet) (result *extensions.DaemonSet, err error) { - result = &extensions.DaemonSet{} - err = c.r.Put().Namespace(c.ns).Resource("daemonsets").Name(daemon.Name).Body(daemon).Do().Into(result) - return -} - -// UpdateStatus updates an existing daemon set status -func (c *daemonSets) UpdateStatus(daemon *extensions.DaemonSet) (result *extensions.DaemonSet, err error) { - result = &extensions.DaemonSet{} - err = c.r.Put().Namespace(c.ns).Resource("daemonsets").Name(daemon.Name).SubResource("status").Body(daemon).Do().Into(result) - return -} - -// Delete deletes an existing daemon set. -func (c *daemonSets) Delete(name string) error { - return c.r.Delete().Namespace(c.ns).Resource("daemonsets").Name(name).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested daemon sets. -func (c *daemonSets) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("daemonsets"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/daemon_sets_test.go b/pkg/client/unversioned/daemon_sets_test.go deleted file mode 100644 index 83b309ac0f804..0000000000000 --- a/pkg/client/unversioned/daemon_sets_test.go +++ /dev/null @@ -1,198 +0,0 @@ -/* -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 unversioned_test - -import ( - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -import ( - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/apis/extensions" -) - -func getDSResourceName() string { - return "daemonsets" -} - -func TestListDaemonSets(t *testing.T) { - ns := api.NamespaceAll - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, ""), - }, - Response: simple.Response{StatusCode: 200, - Body: &extensions.DaemonSetList{ - Items: []extensions.DaemonSet{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.DaemonSetSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - }, - }, - } - receivedDSs, err := c.Setup(t).Extensions().DaemonSets(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, receivedDSs, err) - -} - -func TestGetDaemonSet(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "GET", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.DaemonSet{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.DaemonSetSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - } - receivedDaemonSet, err := c.Setup(t).Extensions().DaemonSets(ns).Get("foo") - defer c.Close() - c.Validate(t, receivedDaemonSet, err) -} - -func TestGetDaemonSetWithNoName(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{Error: true} - receivedPod, err := c.Setup(t).Extensions().DaemonSets(ns).Get("") - defer c.Close() - if (err != nil) && (err.Error() != simple.NameRequiredError) { - t.Errorf("Expected error: %v, but got %v", simple.NameRequiredError, err) - } - - c.Validate(t, receivedPod, err) -} - -func TestUpdateDaemonSet(t *testing.T) { - ns := api.NamespaceDefault - requestDaemonSet := &extensions.DaemonSet{ - ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.DaemonSet{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.DaemonSetSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - } - receivedDaemonSet, err := c.Setup(t).Extensions().DaemonSets(ns).Update(requestDaemonSet) - defer c.Close() - c.Validate(t, receivedDaemonSet, err) -} - -func TestUpdateDaemonSetUpdateStatus(t *testing.T) { - ns := api.NamespaceDefault - requestDaemonSet := &extensions.DaemonSet{ - ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, "foo") + "/status", Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.DaemonSet{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.DaemonSetSpec{ - Template: api.PodTemplateSpec{}, - }, - Status: extensions.DaemonSetStatus{}, - }, - }, - } - receivedDaemonSet, err := c.Setup(t).Extensions().DaemonSets(ns).UpdateStatus(requestDaemonSet) - defer c.Close() - c.Validate(t, receivedDaemonSet, err) -} - -func TestDeleteDaemon(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).Extensions().DaemonSets(ns).Delete("foo") - defer c.Close() - c.Validate(t, nil, err) -} - -func TestCreateDaemonSet(t *testing.T) { - ns := api.NamespaceDefault - requestDaemonSet := &extensions.DaemonSet{ - ObjectMeta: api.ObjectMeta{Name: "foo"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "POST", Path: testapi.Extensions.ResourcePath(getDSResourceName(), ns, ""), Body: requestDaemonSet, Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.DaemonSet{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.DaemonSetSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - } - receivedDaemonSet, err := c.Setup(t).Extensions().DaemonSets(ns).Create(requestDaemonSet) - defer c.Close() - c.Validate(t, receivedDaemonSet, err) -} diff --git a/pkg/client/unversioned/deployment.go b/pkg/client/unversioned/deployment.go deleted file mode 100644 index a5e8afe947fd1..0000000000000 --- a/pkg/client/unversioned/deployment.go +++ /dev/null @@ -1,111 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/watch" -) - -// DeploymentsNamespacer has methods to work with Deployment resources in a namespace -type DeploymentsNamespacer interface { - Deployments(namespace string) DeploymentInterface -} - -// DeploymentInterface has methods to work with Deployment resources. -type DeploymentInterface interface { - List(opts api.ListOptions) (*extensions.DeploymentList, error) - Get(name string) (*extensions.Deployment, error) - Delete(name string, options *api.DeleteOptions) error - Create(*extensions.Deployment) (*extensions.Deployment, error) - Update(*extensions.Deployment) (*extensions.Deployment, error) - UpdateStatus(*extensions.Deployment) (*extensions.Deployment, error) - Watch(opts api.ListOptions) (watch.Interface, error) - Rollback(*extensions.DeploymentRollback) error -} - -// deployments implements DeploymentInterface -type deployments struct { - client *ExtensionsClient - ns string -} - -// Ensure statically that deployments implements DeploymentInterface. -var _ DeploymentInterface = &deployments{} - -// newDeployments returns a Deployments -func newDeployments(c *ExtensionsClient, namespace string) *deployments { - return &deployments{ - client: c, - ns: namespace, - } -} - -// List takes label and field selectors, and returns the list of Deployments that match those selectors. -func (c *deployments) List(opts api.ListOptions) (result *extensions.DeploymentList, err error) { - result = &extensions.DeploymentList{} - err = c.client.Get().Namespace(c.ns).Resource("deployments").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get takes name of the deployment, and returns the corresponding deployment object, and an error if there is any. -func (c *deployments) Get(name string) (result *extensions.Deployment, err error) { - result = &extensions.Deployment{} - err = c.client.Get().Namespace(c.ns).Resource("deployments").Name(name).Do().Into(result) - return -} - -// Delete takes name of the deployment and deletes it. Returns an error if one occurs. -func (c *deployments) Delete(name string, options *api.DeleteOptions) error { - return c.client.Delete().Namespace(c.ns).Resource("deployments").Name(name).Body(options).Do().Error() -} - -// Create takes the representation of a deployment and creates it. Returns the server's representation of the deployment, and an error, if there is any. -func (c *deployments) Create(deployment *extensions.Deployment) (result *extensions.Deployment, err error) { - result = &extensions.Deployment{} - err = c.client.Post().Namespace(c.ns).Resource("deployments").Body(deployment).Do().Into(result) - return -} - -// Update takes the representation of a deployment and updates it. Returns the server's representation of the deployment, and an error, if there is any. -func (c *deployments) Update(deployment *extensions.Deployment) (result *extensions.Deployment, err error) { - result = &extensions.Deployment{} - err = c.client.Put().Namespace(c.ns).Resource("deployments").Name(deployment.Name).Body(deployment).Do().Into(result) - return -} - -func (c *deployments) UpdateStatus(deployment *extensions.Deployment) (result *extensions.Deployment, err error) { - result = &extensions.Deployment{} - err = c.client.Put().Namespace(c.ns).Resource("deployments").Name(deployment.Name).SubResource("status").Body(deployment).Do().Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested deployments. -func (c *deployments) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.client.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("deployments"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -// Rollback applied the provided DeploymentRollback to the named deployment in the current namespace. -func (c *deployments) Rollback(deploymentRollback *extensions.DeploymentRollback) error { - return c.client.Post().Namespace(c.ns).Resource("deployments").Name(deploymentRollback.Name).SubResource("rollback").Body(deploymentRollback).Do().Error() -} diff --git a/pkg/client/unversioned/deployment_test.go b/pkg/client/unversioned/deployment_test.go deleted file mode 100644 index c2351a7c6c118..0000000000000 --- a/pkg/client/unversioned/deployment_test.go +++ /dev/null @@ -1,236 +0,0 @@ -/* -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 unversioned_test - -import ( - "net/http" - "net/url" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" - "k8s.io/kubernetes/pkg/labels" -) - -func getDeploymentsResourceName() string { - return "deployments" -} - -func TestDeploymentCreate(t *testing.T) { - ns := api.NamespaceDefault - deployment := extensions.Deployment{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: ns, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Extensions.ResourcePath(getDeploymentsResourceName(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: &deployment, - }, - Response: simple.Response{StatusCode: 200, Body: &deployment}, - } - - response, err := c.Setup(t).Deployments(ns).Create(&deployment) - defer c.Close() - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - c.Validate(t, response, err) -} - -func TestDeploymentGet(t *testing.T) { - ns := api.NamespaceDefault - deployment := &extensions.Deployment{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: ns, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Extensions.ResourcePath(getDeploymentsResourceName(), ns, "abc"), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: deployment}, - } - - response, err := c.Setup(t).Deployments(ns).Get("abc") - defer c.Close() - c.Validate(t, response, err) -} - -func TestDeploymentList(t *testing.T) { - ns := api.NamespaceDefault - deploymentList := &extensions.DeploymentList{ - Items: []extensions.Deployment{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - }, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Extensions.ResourcePath(getDeploymentsResourceName(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: deploymentList}, - } - response, err := c.Setup(t).Deployments(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, response, err) -} - -func TestDeploymentUpdate(t *testing.T) { - ns := api.NamespaceDefault - deployment := &extensions.Deployment{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: ns, - ResourceVersion: "1", - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Extensions.ResourcePath(getDeploymentsResourceName(), ns, "abc"), - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{StatusCode: 200, Body: deployment}, - } - response, err := c.Setup(t).Deployments(ns).Update(deployment) - defer c.Close() - c.Validate(t, response, err) -} - -func TestDeploymentUpdateStatus(t *testing.T) { - ns := api.NamespaceDefault - deployment := &extensions.Deployment{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: ns, - ResourceVersion: "1", - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Extensions.ResourcePath(getDeploymentsResourceName(), ns, "abc") + "/status", - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{StatusCode: 200, Body: deployment}, - } - response, err := c.Setup(t).Deployments(ns).UpdateStatus(deployment) - defer c.Close() - c.Validate(t, response, err) -} - -func TestDeploymentDelete(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{ - Method: "DELETE", - Path: testapi.Extensions.ResourcePath(getDeploymentsResourceName(), ns, "foo"), - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).Deployments(ns).Delete("foo", nil) - defer c.Close() - c.Validate(t, nil, err) -} - -func TestDeploymentWatch(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Extensions.ResourcePathWithPrefix("watch", getDeploymentsResourceName(), "", ""), - Query: url.Values{"resourceVersion": []string{}}, - }, - Response: simple.Response{StatusCode: 200}, - } - _, err := c.Setup(t).Deployments(api.NamespaceAll).Watch(api.ListOptions{}) - defer c.Close() - c.Validate(t, nil, err) -} - -func TestListDeploymentsLabels(t *testing.T) { - ns := api.NamespaceDefault - labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Extensions.GroupVersion().String()) - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Extensions.ResourcePath("deployments", ns, ""), - Query: simple.BuildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})}, - Response: simple.Response{ - StatusCode: http.StatusOK, - Body: &extensions.DeploymentList{ - Items: []extensions.Deployment{ - { - ObjectMeta: api.ObjectMeta{ - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - }, - }, - }, - }, - } - c.Setup(t) - defer c.Close() - c.QueryValidator[labelSelectorQueryParamName] = simple.ValidateLabels - selector := labels.Set{"foo": "bar", "name": "baz"}.AsSelector() - options := api.ListOptions{LabelSelector: selector} - receivedPodList, err := c.Deployments(ns).List(options) - c.Validate(t, receivedPodList, err) -} - -func TestDeploymentRollback(t *testing.T) { - ns := api.NamespaceDefault - deploymentRollback := &extensions.DeploymentRollback{ - Name: "abc", - UpdatedAnnotations: map[string]string{}, - RollbackTo: extensions.RollbackConfig{Revision: 1}, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Extensions.ResourcePath(getDeploymentsResourceName(), ns, "abc") + "/rollback", - Query: simple.BuildQueryValues(nil), - Body: deploymentRollback, - }, - Response: simple.Response{StatusCode: http.StatusOK}, - } - err := c.Setup(t).Deployments(ns).Rollback(deploymentRollback) - defer c.Close() - c.ValidateCommon(t, err) -} diff --git a/pkg/client/unversioned/doc.go b/pkg/client/unversioned/doc.go deleted file mode 100644 index 4c5a986a0f844..0000000000000 --- a/pkg/client/unversioned/doc.go +++ /dev/null @@ -1,58 +0,0 @@ -/* -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 unversioned contains the implementation of the client side communication with the -Kubernetes master. The Client class provides methods for reading, creating, updating, -and deleting pods, replication controllers, daemons, services, and nodes. - -Most consumers should use the Config object to create a Client: - - import ( - client "k8s.io/kubernetes/pkg/client/unversioned" - "k8s.io/kubernetes/pkg/client/restclient" - "k8s.io/kubernetes/pkg/api" - ) - - [...] - - config := &restclient.Config{ - Host: "http://localhost:8080", - Username: "test", - Password: "password", - } - c, err := client.New(config) - if err != nil { - // handle error - } - pods, err := c.Pods(api.NamespaceDefault).List(api.ListOptions{}) - if err != nil { - // handle error - } - -More advanced consumers may wish to provide their own transport via a http.RoundTripper: - - config := &restclient.Config{ - Host: "https://localhost:8080", - Transport: oauthclient.Transport(), - } - c, err := client.New(config) - -The RESTClient type implements the Kubernetes API conventions (see `docs/devel/api-conventions.md`) -for a given API path and is intended for use by consumers implementing their own Kubernetes -compatible APIs. -*/ -package unversioned // import "k8s.io/kubernetes/pkg/client/unversioned" diff --git a/pkg/client/unversioned/endpoints.go b/pkg/client/unversioned/endpoints.go deleted file mode 100644 index 6e20a347eb58c..0000000000000 --- a/pkg/client/unversioned/endpoints.go +++ /dev/null @@ -1,101 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// EndpointsNamespacer has methods to work with Endpoints resources in a namespace -type EndpointsNamespacer interface { - Endpoints(namespace string) EndpointsInterface -} - -// EndpointsInterface has methods to work with Endpoints resources -type EndpointsInterface interface { - Create(endpoints *api.Endpoints) (*api.Endpoints, error) - List(opts api.ListOptions) (*api.EndpointsList, error) - Get(name string) (*api.Endpoints, error) - Delete(name string) error - Update(endpoints *api.Endpoints) (*api.Endpoints, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// endpoints implements EndpointsInterface -type endpoints struct { - r *Client - ns string -} - -// newEndpoints returns a endpoints -func newEndpoints(c *Client, namespace string) *endpoints { - return &endpoints{c, namespace} -} - -// Create creates a new endpoint. -func (c *endpoints) Create(endpoints *api.Endpoints) (*api.Endpoints, error) { - result := &api.Endpoints{} - err := c.r.Post().Namespace(c.ns).Resource("endpoints").Body(endpoints).Do().Into(result) - return result, err -} - -// List takes a selector, and returns the list of endpoints that match that selector -func (c *endpoints) List(opts api.ListOptions) (result *api.EndpointsList, err error) { - result = &api.EndpointsList{} - err = c.r.Get(). - Namespace(c.ns). - Resource("endpoints"). - VersionedParams(&opts, api.ParameterCodec). - Do(). - Into(result) - return -} - -// Get returns information about the endpoints for a particular service. -func (c *endpoints) Get(name string) (result *api.Endpoints, err error) { - result = &api.Endpoints{} - err = c.r.Get().Namespace(c.ns).Resource("endpoints").Name(name).Do().Into(result) - return -} - -// Delete takes the name of the endpoint, and returns an error if one occurs -func (c *endpoints) Delete(name string) error { - return c.r.Delete().Namespace(c.ns).Resource("endpoints").Name(name).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested endpoints for a service. -func (c *endpoints) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("endpoints"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -func (c *endpoints) Update(endpoints *api.Endpoints) (*api.Endpoints, error) { - result := &api.Endpoints{} - err := c.r.Put(). - Namespace(c.ns). - Resource("endpoints"). - Name(endpoints.Name). - Body(endpoints). - Do(). - Into(result) - return result, err -} diff --git a/pkg/client/unversioned/endpoints_test.go b/pkg/client/unversioned/endpoints_test.go deleted file mode 100644 index 7db891b0c86f1..0000000000000 --- a/pkg/client/unversioned/endpoints_test.go +++ /dev/null @@ -1,71 +0,0 @@ -/* -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 unversioned_test - -import ( - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func TestListEndpoints(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "GET", Path: testapi.Default.ResourcePath("endpoints", ns, ""), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, - Body: &api.EndpointsList{ - Items: []api.Endpoints{ - { - ObjectMeta: api.ObjectMeta{Name: "endpoint-1"}, - Subsets: []api.EndpointSubset{{ - Addresses: []api.EndpointAddress{{IP: "10.245.1.2"}, {IP: "10.245.1.3"}}, - Ports: []api.EndpointPort{{Port: 8080}}, - }}, - }, - }, - }, - }, - } - receivedEndpointsList, err := c.Setup(t).Endpoints(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, receivedEndpointsList, err) -} - -func TestGetEndpoints(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "GET", Path: testapi.Default.ResourcePath("endpoints", ns, "endpoint-1"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "endpoint-1"}}}, - } - response, err := c.Setup(t).Endpoints(ns).Get("endpoint-1") - defer c.Close() - c.Validate(t, response, err) -} - -func TestGetEndpointWithNoName(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{Error: true} - receivedPod, err := c.Setup(t).Endpoints(ns).Get("") - defer c.Close() - if (err != nil) && (err.Error() != simple.NameRequiredError) { - t.Errorf("Expected error: %v, but got %v", simple.NameRequiredError, err) - } - - c.Validate(t, receivedPod, err) -} diff --git a/pkg/client/unversioned/events.go b/pkg/client/unversioned/events.go deleted file mode 100644 index 3421bd8117eb2..0000000000000 --- a/pkg/client/unversioned/events.go +++ /dev/null @@ -1,219 +0,0 @@ -/* -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 unversioned - -import ( - "fmt" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/watch" -) - -// EventNamespacer can return an EventInterface for the given namespace. -type EventNamespacer interface { - Events(namespace string) EventInterface -} - -// EventInterface has methods to work with Event resources -type EventInterface interface { - Create(event *api.Event) (*api.Event, error) - Update(event *api.Event) (*api.Event, error) - Patch(event *api.Event, data []byte) (*api.Event, error) - List(opts api.ListOptions) (*api.EventList, error) - Get(name string) (*api.Event, error) - Watch(opts api.ListOptions) (watch.Interface, error) - // Search finds events about the specified object - Search(objOrRef runtime.Object) (*api.EventList, error) - Delete(name string) error - // DeleteCollection deletes a collection of events. - DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error - // Returns the appropriate field selector based on the API version being used to communicate with the server. - // The returned field selector can be used with List and Watch to filter desired events. - GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector -} - -// events implements Events interface -type events struct { - client *Client - namespace string -} - -// newEvents returns a new events object. -func newEvents(c *Client, ns string) *events { - return &events{ - client: c, - namespace: ns, - } -} - -// Create makes a new event. Returns the copy of the event the server returns, -// or an error. The namespace to create the event within is deduced from the -// event; it must either match this event client's namespace, or this event -// client must have been created with the "" namespace. -func (e *events) Create(event *api.Event) (*api.Event, error) { - if e.namespace != "" && event.Namespace != e.namespace { - return nil, fmt.Errorf("can't create an event with namespace '%v' in namespace '%v'", event.Namespace, e.namespace) - } - result := &api.Event{} - err := e.client.Post(). - Namespace(event.Namespace). - Resource("events"). - Body(event). - Do(). - Into(result) - return result, err -} - -// Update modifies an existing event. It returns the copy of the event that the server returns, -// or an error. The namespace and key to update the event within is deduced from the event. The -// namespace must either match this event client's namespace, or this event client must have been -// created with the "" namespace. Update also requires the ResourceVersion to be set in the event -// object. -func (e *events) Update(event *api.Event) (*api.Event, error) { - result := &api.Event{} - err := e.client.Put(). - Namespace(event.Namespace). - Resource("events"). - Name(event.Name). - Body(event). - Do(). - Into(result) - return result, err -} - -// Patch modifies an existing event. It returns the copy of the event that the server returns, or an -// error. The namespace and name of the target event is deduced from the incompleteEvent. The -// namespace must either match this event client's namespace, or this event client must have been -// created with the "" namespace. -func (e *events) Patch(incompleteEvent *api.Event, data []byte) (*api.Event, error) { - result := &api.Event{} - err := e.client.Patch(api.StrategicMergePatchType). - Namespace(incompleteEvent.Namespace). - Resource("events"). - Name(incompleteEvent.Name). - Body(data). - Do(). - Into(result) - return result, err -} - -// List returns a list of events matching the selectors. -func (e *events) List(opts api.ListOptions) (*api.EventList, error) { - result := &api.EventList{} - err := e.client.Get(). - Namespace(e.namespace). - Resource("events"). - VersionedParams(&opts, api.ParameterCodec). - Do(). - Into(result) - return result, err -} - -// Get returns the given event, or an error. -func (e *events) Get(name string) (*api.Event, error) { - result := &api.Event{} - err := e.client.Get(). - Namespace(e.namespace). - Resource("events"). - Name(name). - Do(). - Into(result) - return result, err -} - -// Watch starts watching for events matching the given selectors. -func (e *events) Watch(opts api.ListOptions) (watch.Interface, error) { - return e.client.Get(). - Prefix("watch"). - Namespace(e.namespace). - Resource("events"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -// Search finds events about the specified object. The namespace of the -// object must match this event's client namespace unless the event client -// was made with the "" namespace. -func (e *events) Search(objOrRef runtime.Object) (*api.EventList, error) { - ref, err := api.GetReference(objOrRef) - if err != nil { - return nil, err - } - if e.namespace != "" && ref.Namespace != e.namespace { - return nil, fmt.Errorf("won't be able to find any events of namespace '%v' in namespace '%v'", ref.Namespace, e.namespace) - } - stringRefKind := string(ref.Kind) - var refKind *string - if stringRefKind != "" { - refKind = &stringRefKind - } - stringRefUID := string(ref.UID) - var refUID *string - if stringRefUID != "" { - refUID = &stringRefUID - } - fieldSelector := e.GetFieldSelector(&ref.Name, &ref.Namespace, refKind, refUID) - return e.List(api.ListOptions{FieldSelector: fieldSelector}) -} - -// Delete deletes an existing event. -func (e *events) Delete(name string) error { - return e.client.Delete(). - Namespace(e.namespace). - Resource("events"). - Name(name). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (e *events) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { - return e.client.Delete(). - Namespace(e.namespace). - Resource("events"). - VersionedParams(&listOptions, api.ParameterCodec). - Body(options). - Do(). - Error() -} - -// Returns the appropriate field selector based on the API version being used to communicate with the server. -// The returned field selector can be used with List and Watch to filter desired events. -func (e *events) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector { - apiVersion := e.client.APIVersion().String() - field := fields.Set{} - if involvedObjectName != nil { - field[GetInvolvedObjectNameFieldLabel(apiVersion)] = *involvedObjectName - } - if involvedObjectNamespace != nil { - field["involvedObject.namespace"] = *involvedObjectNamespace - } - if involvedObjectKind != nil { - field["involvedObject.kind"] = *involvedObjectKind - } - if involvedObjectUID != nil { - field["involvedObject.uid"] = *involvedObjectUID - } - return field.AsSelector() -} - -// Returns the appropriate field label to use for name of the involved object as per the given API version. -func GetInvolvedObjectNameFieldLabel(version string) string { - return "involvedObject.name" -} diff --git a/pkg/client/unversioned/events_test.go b/pkg/client/unversioned/events_test.go deleted file mode 100644 index baf719431ff84..0000000000000 --- a/pkg/client/unversioned/events_test.go +++ /dev/null @@ -1,206 +0,0 @@ -/* -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 unversioned_test - -import ( - . "k8s.io/kubernetes/pkg/client/unversioned" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -import ( - "net/url" - "reflect" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/apimachinery/registered" -) - -func TestEventSearch(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath("events", "baz", ""), - Query: url.Values{ - unversioned.FieldSelectorQueryParam(registered.GroupOrDie(api.GroupName).GroupVersion.String()): []string{ - GetInvolvedObjectNameFieldLabel(registered.GroupOrDie(api.GroupName).GroupVersion.String()) + "=foo,", - "involvedObject.namespace=baz,", - "involvedObject.kind=Pod", - }, - unversioned.LabelSelectorQueryParam(registered.GroupOrDie(api.GroupName).GroupVersion.String()): []string{}, - }, - }, - Response: simple.Response{StatusCode: 200, Body: &api.EventList{}}, - } - eventList, err := c.Setup(t).Events("baz").Search( - &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: "baz", - SelfLink: testapi.Default.SelfLink("pods", ""), - }, - }, - ) - defer c.Close() - c.Validate(t, eventList, err) -} - -func TestEventCreate(t *testing.T) { - objReference := &api.ObjectReference{ - Kind: "foo", - Namespace: "nm", - Name: "objref1", - UID: "uid", - APIVersion: "apiv1", - ResourceVersion: "1", - } - timeStamp := unversioned.Now() - event := &api.Event{ - ObjectMeta: api.ObjectMeta{ - Namespace: api.NamespaceDefault, - }, - InvolvedObject: *objReference, - FirstTimestamp: timeStamp, - LastTimestamp: timeStamp, - Count: 1, - Type: api.EventTypeNormal, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Default.ResourcePath("events", api.NamespaceDefault, ""), - Body: event, - }, - Response: simple.Response{StatusCode: 200, Body: event}, - } - - response, err := c.Setup(t).Events(api.NamespaceDefault).Create(event) - defer c.Close() - - if err != nil { - t.Fatalf("%v should be nil.", err) - } - - if e, a := *objReference, response.InvolvedObject; !reflect.DeepEqual(e, a) { - t.Errorf("%#v != %#v.", e, a) - } -} - -func TestEventGet(t *testing.T) { - objReference := &api.ObjectReference{ - Kind: "foo", - Namespace: "nm", - Name: "objref1", - UID: "uid", - APIVersion: "apiv1", - ResourceVersion: "1", - } - timeStamp := unversioned.Now() - event := &api.Event{ - ObjectMeta: api.ObjectMeta{ - Namespace: "other", - }, - InvolvedObject: *objReference, - FirstTimestamp: timeStamp, - LastTimestamp: timeStamp, - Count: 1, - Type: api.EventTypeNormal, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath("events", "other", "1"), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: event}, - } - - response, err := c.Setup(t).Events("other").Get("1") - defer c.Close() - - if err != nil { - t.Fatalf("%v should be nil.", err) - } - - if e, r := event.InvolvedObject, response.InvolvedObject; !reflect.DeepEqual(e, r) { - t.Errorf("%#v != %#v.", e, r) - } -} - -func TestEventList(t *testing.T) { - ns := api.NamespaceDefault - objReference := &api.ObjectReference{ - Kind: "foo", - Namespace: ns, - Name: "objref1", - UID: "uid", - APIVersion: "apiv1", - ResourceVersion: "1", - } - timeStamp := unversioned.Now() - eventList := &api.EventList{ - Items: []api.Event{ - { - InvolvedObject: *objReference, - FirstTimestamp: timeStamp, - LastTimestamp: timeStamp, - Count: 1, - Type: api.EventTypeNormal, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath("events", ns, ""), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: eventList}, - } - response, err := c.Setup(t).Events(ns).List(api.ListOptions{}) - defer c.Close() - - if err != nil { - t.Errorf("%#v should be nil.", err) - } - - if len(response.Items) != 1 { - t.Errorf("%#v response.Items should have len 1.", response.Items) - } - - responseEvent := response.Items[0] - if e, r := eventList.Items[0].InvolvedObject, - responseEvent.InvolvedObject; !reflect.DeepEqual(e, r) { - t.Errorf("%#v != %#v.", e, r) - } -} - -func TestEventDelete(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{ - Method: "DELETE", - Path: testapi.Default.ResourcePath("events", ns, "foo"), - }, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).Events(ns).Delete("foo") - defer c.Close() - c.Validate(t, nil, err) -} diff --git a/pkg/client/unversioned/extensions.go b/pkg/client/unversioned/extensions.go deleted file mode 100644 index f538055a0f6de..0000000000000 --- a/pkg/client/unversioned/extensions.go +++ /dev/null @@ -1,109 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/client/restclient" -) - -// Interface holds the experimental methods for clients of Kubernetes -// to allow mock testing. -// Features of Extensions group are not supported and may be changed or removed in -// incompatible ways at any time. -type ExtensionsInterface interface { - ScaleNamespacer - DaemonSetsNamespacer - DeploymentsNamespacer - JobsNamespacer - IngressNamespacer - NetworkPolicyNamespacer - ThirdPartyResourceNamespacer - ReplicaSetsNamespacer - PodSecurityPoliciesInterface -} - -// ExtensionsClient is used to interact with experimental Kubernetes features. -// Features of Extensions group are not supported and may be changed or removed in -// incompatible ways at any time. -type ExtensionsClient struct { - *restclient.RESTClient -} - -func (c *ExtensionsClient) PodSecurityPolicies() PodSecurityPolicyInterface { - return newPodSecurityPolicy(c) -} - -func (c *ExtensionsClient) Scales(namespace string) ScaleInterface { - return newScales(c, namespace) -} - -func (c *ExtensionsClient) DaemonSets(namespace string) DaemonSetInterface { - return newDaemonSets(c, namespace) -} - -func (c *ExtensionsClient) Deployments(namespace string) DeploymentInterface { - return newDeployments(c, namespace) -} - -func (c *ExtensionsClient) Jobs(namespace string) JobInterface { - return newJobs(c, namespace) -} - -func (c *ExtensionsClient) Ingress(namespace string) IngressInterface { - return newIngress(c, namespace) -} - -func (c *ExtensionsClient) NetworkPolicies(namespace string) NetworkPolicyInterface { - return newNetworkPolicies(c, namespace) -} - -func (c *ExtensionsClient) ThirdPartyResources() ThirdPartyResourceInterface { - return newThirdPartyResources(c) -} - -func (c *ExtensionsClient) ReplicaSets(namespace string) ReplicaSetInterface { - return newReplicaSets(c, namespace) -} - -// NewExtensions creates a new ExtensionsClient for the given config. This client -// provides access to experimental Kubernetes features. -// Features of Extensions group are not supported and may be changed or removed in -// incompatible ways at any time. -func NewExtensions(c *restclient.Config) (*ExtensionsClient, error) { - config := *c - if err := setGroupDefaults(extensions.GroupName, &config); err != nil { - return nil, err - } - client, err := restclient.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &ExtensionsClient{client}, nil -} - -// NewExtensionsOrDie creates a new ExtensionsClient for the given config and -// panics if there is an error in the config. -// Features of Extensions group are not supported and may be changed or removed in -// incompatible ways at any time. -func NewExtensionsOrDie(c *restclient.Config) *ExtensionsClient { - client, err := NewExtensions(c) - if err != nil { - panic(err) - } - return client -} diff --git a/pkg/client/unversioned/flags.go b/pkg/client/unversioned/flags.go deleted file mode 100644 index 7d32a259df33c..0000000000000 --- a/pkg/client/unversioned/flags.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -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 unversioned - -import ( - "time" -) - -// FlagSet abstracts the flag interface for compatibility with both Golang "flag" -// and cobra pflags (Posix style). -type FlagSet interface { - StringVar(p *string, name, value, usage string) - BoolVar(p *bool, name string, value bool, usage string) - UintVar(p *uint, name string, value uint, usage string) - DurationVar(p *time.Duration, name string, value time.Duration, usage string) - IntVar(p *int, name string, value int, usage string) -} diff --git a/pkg/client/unversioned/flags_test.go b/pkg/client/unversioned/flags_test.go deleted file mode 100644 index 455ee7df12f84..0000000000000 --- a/pkg/client/unversioned/flags_test.go +++ /dev/null @@ -1,79 +0,0 @@ -/* -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 unversioned - -import ( - "testing" - "time" - - "k8s.io/kubernetes/pkg/util/sets" -) - -type fakeFlagSet struct { - t *testing.T - set sets.String -} - -func (f *fakeFlagSet) StringVar(p *string, name, value, usage string) { - if p == nil { - f.t.Errorf("unexpected nil pointer") - } - if usage == "" { - f.t.Errorf("unexpected empty usage") - } - f.set.Insert(name) -} - -func (f *fakeFlagSet) BoolVar(p *bool, name string, value bool, usage string) { - if p == nil { - f.t.Errorf("unexpected nil pointer") - } - if usage == "" { - f.t.Errorf("unexpected empty usage") - } - f.set.Insert(name) -} - -func (f *fakeFlagSet) UintVar(p *uint, name string, value uint, usage string) { - if p == nil { - f.t.Errorf("unexpected nil pointer") - } - if usage == "" { - f.t.Errorf("unexpected empty usage") - } - f.set.Insert(name) -} - -func (f *fakeFlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string) { - if p == nil { - f.t.Errorf("unexpected nil pointer") - } - if usage == "" { - f.t.Errorf("unexpected empty usage") - } - f.set.Insert(name) -} - -func (f *fakeFlagSet) IntVar(p *int, name string, value int, usage string) { - if p == nil { - f.t.Errorf("unexpected nil pointer") - } - if usage == "" { - f.t.Errorf("unexpected empty usage") - } - f.set.Insert(name) -} diff --git a/pkg/client/unversioned/horizontalpodautoscaler.go b/pkg/client/unversioned/horizontalpodautoscaler.go deleted file mode 100644 index 76c6a9cf9d782..0000000000000 --- a/pkg/client/unversioned/horizontalpodautoscaler.go +++ /dev/null @@ -1,103 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/autoscaling" - "k8s.io/kubernetes/pkg/watch" -) - -// HorizontalPodAutoscalersNamespacer has methods to work with HorizontalPodAutoscaler resources in a namespace -type HorizontalPodAutoscalersNamespacer interface { - HorizontalPodAutoscalers(namespace string) HorizontalPodAutoscalerInterface -} - -// HorizontalPodAutoscalerInterface has methods to work with HorizontalPodAutoscaler resources. -type HorizontalPodAutoscalerInterface interface { - List(opts api.ListOptions) (*autoscaling.HorizontalPodAutoscalerList, error) - Get(name string) (*autoscaling.HorizontalPodAutoscaler, error) - Delete(name string, options *api.DeleteOptions) error - Create(horizontalPodAutoscaler *autoscaling.HorizontalPodAutoscaler) (*autoscaling.HorizontalPodAutoscaler, error) - Update(horizontalPodAutoscaler *autoscaling.HorizontalPodAutoscaler) (*autoscaling.HorizontalPodAutoscaler, error) - UpdateStatus(horizontalPodAutoscaler *autoscaling.HorizontalPodAutoscaler) (*autoscaling.HorizontalPodAutoscaler, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// horizontalPodAutoscalers implements HorizontalPodAutoscalersNamespacer interface using AutoscalingClient internally -type horizontalPodAutoscalers struct { - client *AutoscalingClient - ns string -} - -// newHorizontalPodAutoscalers returns a horizontalPodAutoscalers -func newHorizontalPodAutoscalers(c *AutoscalingClient, namespace string) *horizontalPodAutoscalers { - return &horizontalPodAutoscalers{ - client: c, - ns: namespace, - } -} - -// List takes label and field selectors, and returns the list of horizontalPodAutoscalers that match those selectors. -func (c *horizontalPodAutoscalers) List(opts api.ListOptions) (result *autoscaling.HorizontalPodAutoscalerList, err error) { - result = &autoscaling.HorizontalPodAutoscalerList{} - err = c.client.Get().Namespace(c.ns).Resource("horizontalPodAutoscalers").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get takes the name of the horizontalPodAutoscaler, and returns the corresponding HorizontalPodAutoscaler object, and an error if it occurs -func (c *horizontalPodAutoscalers) Get(name string) (result *autoscaling.HorizontalPodAutoscaler, err error) { - result = &autoscaling.HorizontalPodAutoscaler{} - err = c.client.Get().Namespace(c.ns).Resource("horizontalPodAutoscalers").Name(name).Do().Into(result) - return -} - -// Delete takes the name of the horizontalPodAutoscaler and deletes it. Returns an error if one occurs. -func (c *horizontalPodAutoscalers) Delete(name string, options *api.DeleteOptions) error { - return c.client.Delete().Namespace(c.ns).Resource("horizontalPodAutoscalers").Name(name).Body(options).Do().Error() -} - -// Create takes the representation of a horizontalPodAutoscaler and creates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if it occurs. -func (c *horizontalPodAutoscalers) Create(horizontalPodAutoscaler *autoscaling.HorizontalPodAutoscaler) (result *autoscaling.HorizontalPodAutoscaler, err error) { - result = &autoscaling.HorizontalPodAutoscaler{} - err = c.client.Post().Namespace(c.ns).Resource("horizontalPodAutoscalers").Body(horizontalPodAutoscaler).Do().Into(result) - return -} - -// Update takes the representation of a horizontalPodAutoscaler and updates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if it occurs. -func (c *horizontalPodAutoscalers) Update(horizontalPodAutoscaler *autoscaling.HorizontalPodAutoscaler) (result *autoscaling.HorizontalPodAutoscaler, err error) { - result = &autoscaling.HorizontalPodAutoscaler{} - err = c.client.Put().Namespace(c.ns).Resource("horizontalPodAutoscalers").Name(horizontalPodAutoscaler.Name).Body(horizontalPodAutoscaler).Do().Into(result) - return -} - -// UpdateStatus takes the representation of a horizontalPodAutoscaler and updates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if it occurs. -func (c *horizontalPodAutoscalers) UpdateStatus(horizontalPodAutoscaler *autoscaling.HorizontalPodAutoscaler) (result *autoscaling.HorizontalPodAutoscaler, err error) { - result = &autoscaling.HorizontalPodAutoscaler{} - err = c.client.Put().Namespace(c.ns).Resource("horizontalPodAutoscalers").Name(horizontalPodAutoscaler.Name).SubResource("status").Body(horizontalPodAutoscaler).Do().Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested horizontalPodAutoscalers. -func (c *horizontalPodAutoscalers) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.client.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("horizontalPodAutoscalers"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/horizontalpodautoscaler_test.go b/pkg/client/unversioned/horizontalpodautoscaler_test.go deleted file mode 100644 index 60836435437fa..0000000000000 --- a/pkg/client/unversioned/horizontalpodautoscaler_test.go +++ /dev/null @@ -1,173 +0,0 @@ -/* -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 unversioned_test - -import ( - "net/url" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/apis/autoscaling" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getHorizontalPodAutoscalersResoureName() string { - return "horizontalpodautoscalers" -} - -func TestHorizontalPodAutoscalerCreate(t *testing.T) { - ns := api.NamespaceDefault - horizontalPodAutoscaler := autoscaling.HorizontalPodAutoscaler{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: ns, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: &horizontalPodAutoscaler, - }, - Response: simple.Response{StatusCode: 200, Body: &horizontalPodAutoscaler}, - ResourceGroup: autoscaling.GroupName, - } - - response, err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).Create(&horizontalPodAutoscaler) - defer c.Close() - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - c.Validate(t, response, err) -} - -func TestHorizontalPodAutoscalerGet(t *testing.T) { - ns := api.NamespaceDefault - horizontalPodAutoscaler := &autoscaling.HorizontalPodAutoscaler{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: ns, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "abc"), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: horizontalPodAutoscaler}, - ResourceGroup: autoscaling.GroupName, - } - - response, err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).Get("abc") - defer c.Close() - c.Validate(t, response, err) -} - -func TestHorizontalPodAutoscalerList(t *testing.T) { - ns := api.NamespaceDefault - horizontalPodAutoscalerList := &autoscaling.HorizontalPodAutoscalerList{ - Items: []autoscaling.HorizontalPodAutoscaler{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - }, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: horizontalPodAutoscalerList}, - ResourceGroup: autoscaling.GroupName, - } - response, err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, response, err) -} - -func TestHorizontalPodAutoscalerUpdate(t *testing.T) { - ns := api.NamespaceDefault - horizontalPodAutoscaler := &autoscaling.HorizontalPodAutoscaler{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: ns, - ResourceVersion: "1", - }, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "abc"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: horizontalPodAutoscaler}, - ResourceGroup: autoscaling.GroupName, - } - response, err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).Update(horizontalPodAutoscaler) - defer c.Close() - c.Validate(t, response, err) -} - -func TestHorizontalPodAutoscalerUpdateStatus(t *testing.T) { - ns := api.NamespaceDefault - horizontalPodAutoscaler := &autoscaling.HorizontalPodAutoscaler{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: ns, - ResourceVersion: "1", - }, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "abc") + "/status", Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: horizontalPodAutoscaler}, - ResourceGroup: autoscaling.GroupName, - } - response, err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).UpdateStatus(horizontalPodAutoscaler) - defer c.Close() - c.Validate(t, response, err) -} - -func TestHorizontalPodAutoscalerDelete(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Autoscaling.ResourcePath(getHorizontalPodAutoscalersResoureName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - ResourceGroup: autoscaling.GroupName, - } - err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(ns).Delete("foo", nil) - defer c.Close() - c.Validate(t, nil, err) -} - -func TestHorizontalPodAutoscalerWatch(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Autoscaling.ResourcePathWithPrefix("watch", getHorizontalPodAutoscalersResoureName(), "", ""), - Query: url.Values{"resourceVersion": []string{}}}, - Response: simple.Response{StatusCode: 200}, - ResourceGroup: autoscaling.GroupName, - } - _, err := c.Setup(t).Autoscaling().HorizontalPodAutoscalers(api.NamespaceAll).Watch(api.ListOptions{}) - defer c.Close() - c.Validate(t, nil, err) -} diff --git a/pkg/client/unversioned/import_known_versions.go b/pkg/client/unversioned/import_known_versions.go deleted file mode 100644 index 85dc5bb10d52c..0000000000000 --- a/pkg/client/unversioned/import_known_versions.go +++ /dev/null @@ -1,42 +0,0 @@ -/* -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 unversioned - -// These imports are the API groups the client will support. -import ( - "fmt" - - _ "k8s.io/kubernetes/pkg/api/install" - "k8s.io/kubernetes/pkg/apimachinery/registered" - _ "k8s.io/kubernetes/pkg/apis/apps/install" - _ "k8s.io/kubernetes/pkg/apis/authentication/install" - _ "k8s.io/kubernetes/pkg/apis/authorization/install" - _ "k8s.io/kubernetes/pkg/apis/autoscaling/install" - _ "k8s.io/kubernetes/pkg/apis/batch/install" - _ "k8s.io/kubernetes/pkg/apis/certificates/install" - _ "k8s.io/kubernetes/pkg/apis/componentconfig/install" - _ "k8s.io/kubernetes/pkg/apis/extensions/install" - _ "k8s.io/kubernetes/pkg/apis/policy/install" - _ "k8s.io/kubernetes/pkg/apis/rbac/install" - _ "k8s.io/kubernetes/pkg/apis/storage/install" -) - -func init() { - if missingVersions := registered.ValidateEnvRequestedVersions(); len(missingVersions) != 0 { - panic(fmt.Sprintf("KUBE_API_VERSIONS contains versions that are not installed: %q.", missingVersions)) - } -} diff --git a/pkg/client/unversioned/ingress.go b/pkg/client/unversioned/ingress.go deleted file mode 100644 index 59c6a6d9f8eaa..0000000000000 --- a/pkg/client/unversioned/ingress.go +++ /dev/null @@ -1,100 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/watch" -) - -// IngressNamespacer has methods to work with Ingress resources in a namespace -type IngressNamespacer interface { - Ingress(namespace string) IngressInterface -} - -// IngressInterface exposes methods to work on Ingress resources. -type IngressInterface interface { - List(opts api.ListOptions) (*extensions.IngressList, error) - Get(name string) (*extensions.Ingress, error) - Create(ingress *extensions.Ingress) (*extensions.Ingress, error) - Update(ingress *extensions.Ingress) (*extensions.Ingress, error) - Delete(name string, options *api.DeleteOptions) error - Watch(opts api.ListOptions) (watch.Interface, error) - UpdateStatus(ingress *extensions.Ingress) (*extensions.Ingress, error) -} - -// ingress implements IngressNamespacer interface -type ingress struct { - r *ExtensionsClient - ns string -} - -// newIngress returns a ingress -func newIngress(c *ExtensionsClient, namespace string) *ingress { - return &ingress{c, namespace} -} - -// List returns a list of ingress that match the label and field selectors. -func (c *ingress) List(opts api.ListOptions) (result *extensions.IngressList, err error) { - result = &extensions.IngressList{} - err = c.r.Get().Namespace(c.ns).Resource("ingresses").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get returns information about a particular ingress. -func (c *ingress) Get(name string) (result *extensions.Ingress, err error) { - result = &extensions.Ingress{} - err = c.r.Get().Namespace(c.ns).Resource("ingresses").Name(name).Do().Into(result) - return -} - -// Create creates a new ingress. -func (c *ingress) Create(ingress *extensions.Ingress) (result *extensions.Ingress, err error) { - result = &extensions.Ingress{} - err = c.r.Post().Namespace(c.ns).Resource("ingresses").Body(ingress).Do().Into(result) - return -} - -// Update updates an existing ingress. -func (c *ingress) Update(ingress *extensions.Ingress) (result *extensions.Ingress, err error) { - result = &extensions.Ingress{} - err = c.r.Put().Namespace(c.ns).Resource("ingresses").Name(ingress.Name).Body(ingress).Do().Into(result) - return -} - -// Delete deletes a ingress, returns error if one occurs. -func (c *ingress) Delete(name string, options *api.DeleteOptions) (err error) { - return c.r.Delete().Namespace(c.ns).Resource("ingresses").Name(name).Body(options).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested ingress. -func (c *ingress) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("ingresses"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -// UpdateStatus takes the name of the ingress and the new status. Returns the server's representation of the ingress, and an error, if it occurs. -func (c *ingress) UpdateStatus(ingress *extensions.Ingress) (result *extensions.Ingress, err error) { - result = &extensions.Ingress{} - err = c.r.Put().Namespace(c.ns).Resource("ingresses").Name(ingress.Name).SubResource("status").Body(ingress).Do().Into(result) - return -} diff --git a/pkg/client/unversioned/ingress_test.go b/pkg/client/unversioned/ingress_test.go deleted file mode 100644 index 0dc4e71ca7efc..0000000000000 --- a/pkg/client/unversioned/ingress_test.go +++ /dev/null @@ -1,236 +0,0 @@ -/* -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 unversioned_test - -import ( - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getIngressResourceName() string { - return "ingresses" -} - -func TestListIngress(t *testing.T) { - ns := api.NamespaceAll - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Extensions.ResourcePath(getIngressResourceName(), ns, ""), - }, - Response: simple.Response{StatusCode: 200, - Body: &extensions.IngressList{ - Items: []extensions.Ingress{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.IngressSpec{ - Rules: []extensions.IngressRule{}, - }, - }, - }, - }, - }, - } - receivedIngressList, err := c.Setup(t).Extensions().Ingress(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, receivedIngressList, err) -} - -func TestGetIngress(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Extensions.ResourcePath(getIngressResourceName(), ns, "foo"), - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.Ingress{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.IngressSpec{ - Rules: []extensions.IngressRule{}, - }, - }, - }, - } - receivedIngress, err := c.Setup(t).Extensions().Ingress(ns).Get("foo") - defer c.Close() - c.Validate(t, receivedIngress, err) -} - -func TestGetIngressWithNoName(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{Error: true} - receivedIngress, err := c.Setup(t).Extensions().Ingress(ns).Get("") - defer c.Close() - if (err != nil) && (err.Error() != simple.NameRequiredError) { - t.Errorf("Expected error: %v, but got %v", simple.NameRequiredError, err) - } - - c.Validate(t, receivedIngress, err) -} - -func TestUpdateIngress(t *testing.T) { - ns := api.NamespaceDefault - requestIngress := &extensions.Ingress{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - ResourceVersion: "1", - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Extensions.ResourcePath(getIngressResourceName(), ns, "foo"), - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.Ingress{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.IngressSpec{ - Rules: []extensions.IngressRule{}, - }, - }, - }, - } - receivedIngress, err := c.Setup(t).Extensions().Ingress(ns).Update(requestIngress) - defer c.Close() - c.Validate(t, receivedIngress, err) -} - -func TestUpdateIngressStatus(t *testing.T) { - ns := api.NamespaceDefault - lbStatus := api.LoadBalancerStatus{ - Ingress: []api.LoadBalancerIngress{ - {IP: "127.0.0.1"}, - }, - } - requestIngress := &extensions.Ingress{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - ResourceVersion: "1", - }, - Status: extensions.IngressStatus{ - LoadBalancer: lbStatus, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Extensions.ResourcePath(getIngressResourceName(), ns, "foo") + "/status", - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.Ingress{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.IngressSpec{ - Rules: []extensions.IngressRule{}, - }, - Status: extensions.IngressStatus{ - LoadBalancer: lbStatus, - }, - }, - }, - } - receivedIngress, err := c.Setup(t).Extensions().Ingress(ns).UpdateStatus(requestIngress) - defer c.Close() - c.Validate(t, receivedIngress, err) -} - -func TestDeleteIngress(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{ - Method: "DELETE", - Path: testapi.Extensions.ResourcePath(getIngressResourceName(), ns, "foo"), - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).Extensions().Ingress(ns).Delete("foo", nil) - defer c.Close() - c.Validate(t, nil, err) -} - -func TestCreateIngress(t *testing.T) { - ns := api.NamespaceDefault - requestIngress := &extensions.Ingress{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Extensions.ResourcePath(getIngressResourceName(), ns, ""), - Body: requestIngress, - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.Ingress{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.IngressSpec{ - Rules: []extensions.IngressRule{}, - }, - }, - }, - } - receivedIngress, err := c.Setup(t).Extensions().Ingress(ns).Create(requestIngress) - defer c.Close() - c.Validate(t, receivedIngress, err) -} diff --git a/pkg/client/unversioned/jobs.go b/pkg/client/unversioned/jobs.go deleted file mode 100644 index 14cfa3a30b83c..0000000000000 --- a/pkg/client/unversioned/jobs.go +++ /dev/null @@ -1,167 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/batch" - "k8s.io/kubernetes/pkg/watch" -) - -// JobsNamespacer has methods to work with Job resources in a namespace -type JobsNamespacer interface { - Jobs(namespace string) JobInterface -} - -// JobInterface exposes methods to work on Job resources. -type JobInterface interface { - List(opts api.ListOptions) (*batch.JobList, error) - Get(name string) (*batch.Job, error) - Create(job *batch.Job) (*batch.Job, error) - Update(job *batch.Job) (*batch.Job, error) - Delete(name string, options *api.DeleteOptions) error - Watch(opts api.ListOptions) (watch.Interface, error) - UpdateStatus(job *batch.Job) (*batch.Job, error) -} - -// jobs implements JobsNamespacer interface -type jobs struct { - r *ExtensionsClient - ns string -} - -// newJobs returns a jobs -func newJobs(c *ExtensionsClient, namespace string) *jobs { - return &jobs{c, namespace} -} - -// Ensure statically that jobs implements JobInterface. -var _ JobInterface = &jobs{} - -// List returns a list of jobs that match the label and field selectors. -func (c *jobs) List(opts api.ListOptions) (result *batch.JobList, err error) { - result = &batch.JobList{} - err = c.r.Get().Namespace(c.ns).Resource("jobs").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get returns information about a particular job. -func (c *jobs) Get(name string) (result *batch.Job, err error) { - result = &batch.Job{} - err = c.r.Get().Namespace(c.ns).Resource("jobs").Name(name).Do().Into(result) - return -} - -// Create creates a new job. -func (c *jobs) Create(job *batch.Job) (result *batch.Job, err error) { - result = &batch.Job{} - err = c.r.Post().Namespace(c.ns).Resource("jobs").Body(job).Do().Into(result) - return -} - -// Update updates an existing job. -func (c *jobs) Update(job *batch.Job) (result *batch.Job, err error) { - result = &batch.Job{} - err = c.r.Put().Namespace(c.ns).Resource("jobs").Name(job.Name).Body(job).Do().Into(result) - return -} - -// Delete deletes a job, returns error if one occurs. -func (c *jobs) Delete(name string, options *api.DeleteOptions) (err error) { - return c.r.Delete().Namespace(c.ns).Resource("jobs").Name(name).Body(options).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested jobs. -func (c *jobs) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("jobs"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -// UpdateStatus takes the name of the job and the new status. Returns the server's representation of the job, and an error, if it occurs. -func (c *jobs) UpdateStatus(job *batch.Job) (result *batch.Job, err error) { - result = &batch.Job{} - err = c.r.Put().Namespace(c.ns).Resource("jobs").Name(job.Name).SubResource("status").Body(job).Do().Into(result) - return -} - -// jobsV1 implements JobsNamespacer interface using BatchClient internally -type jobsV1 struct { - r *BatchClient - ns string -} - -// newJobsV1 returns a jobsV1 -func newJobsV1(c *BatchClient, namespace string) *jobsV1 { - return &jobsV1{c, namespace} -} - -// Ensure statically that jobsV1 implements JobInterface. -var _ JobInterface = &jobsV1{} - -// List returns a list of jobs that match the label and field selectors. -func (c *jobsV1) List(opts api.ListOptions) (result *batch.JobList, err error) { - result = &batch.JobList{} - err = c.r.Get().Namespace(c.ns).Resource("jobs").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get returns information about a particular job. -func (c *jobsV1) Get(name string) (result *batch.Job, err error) { - result = &batch.Job{} - err = c.r.Get().Namespace(c.ns).Resource("jobs").Name(name).Do().Into(result) - return -} - -// Create creates a new job. -func (c *jobsV1) Create(job *batch.Job) (result *batch.Job, err error) { - result = &batch.Job{} - err = c.r.Post().Namespace(c.ns).Resource("jobs").Body(job).Do().Into(result) - return -} - -// Update updates an existing job. -func (c *jobsV1) Update(job *batch.Job) (result *batch.Job, err error) { - result = &batch.Job{} - err = c.r.Put().Namespace(c.ns).Resource("jobs").Name(job.Name).Body(job).Do().Into(result) - return -} - -// Delete deletes a job, returns error if one occurs. -func (c *jobsV1) Delete(name string, options *api.DeleteOptions) (err error) { - return c.r.Delete().Namespace(c.ns).Resource("jobs").Name(name).Body(options).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested jobs. -func (c *jobsV1) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("jobs"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -// UpdateStatus takes the name of the job and the new status. Returns the server's representation of the job, and an error, if it occurs. -func (c *jobsV1) UpdateStatus(job *batch.Job) (result *batch.Job, err error) { - result = &batch.Job{} - err = c.r.Put().Namespace(c.ns).Resource("jobs").Name(job.Name).SubResource("status").Body(job).Do().Into(result) - return -} diff --git a/pkg/client/unversioned/jobs_test.go b/pkg/client/unversioned/jobs_test.go deleted file mode 100644 index 8b198701a0516..0000000000000 --- a/pkg/client/unversioned/jobs_test.go +++ /dev/null @@ -1,269 +0,0 @@ -/* -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 unversioned_test - -import ( - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/apis/batch" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/client/unversioned" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getJobsResourceName() string { - return "jobs" -} - -func getJobClient(t *testing.T, c *simple.Client, ns, resourceGroup string) unversioned.JobInterface { - switch resourceGroup { - case batch.GroupName: - return c.Setup(t).Batch().Jobs(ns) - case extensions.GroupName: - return c.Setup(t).Extensions().Jobs(ns) - default: - t.Fatalf("Unknown group %v", resourceGroup) - } - return nil -} - -func testListJob(t *testing.T, group testapi.TestGroup, resourceGroup string) { - ns := api.NamespaceAll - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: group.ResourcePath(getJobsResourceName(), ns, ""), - }, - Response: simple.Response{StatusCode: 200, - Body: &batch.JobList{ - Items: []batch.Job{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: batch.JobSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - }, - }, - ResourceGroup: resourceGroup, - } - receivedJobList, err := getJobClient(t, c, ns, resourceGroup).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, receivedJobList, err) -} - -func TestListJob(t *testing.T) { - testListJob(t, testapi.Extensions, extensions.GroupName) - testListJob(t, testapi.Batch, batch.GroupName) -} - -func testGetJob(t *testing.T, group testapi.TestGroup, resourceGroup string) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: group.ResourcePath(getJobsResourceName(), ns, "foo"), - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &batch.Job{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: batch.JobSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - ResourceGroup: resourceGroup, - } - receivedJob, err := getJobClient(t, c, ns, resourceGroup).Get("foo") - defer c.Close() - c.Validate(t, receivedJob, err) -} - -func TestGetJob(t *testing.T) { - testGetJob(t, testapi.Extensions, extensions.GroupName) - testGetJob(t, testapi.Batch, batch.GroupName) -} - -func testUpdateJob(t *testing.T, group testapi.TestGroup, resourceGroup string) { - ns := api.NamespaceDefault - requestJob := &batch.Job{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - ResourceVersion: "1", - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: group.ResourcePath(getJobsResourceName(), ns, "foo"), - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &batch.Job{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: batch.JobSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - ResourceGroup: resourceGroup, - } - receivedJob, err := getJobClient(t, c, ns, resourceGroup).Update(requestJob) - defer c.Close() - c.Validate(t, receivedJob, err) -} - -func TestUpdateJob(t *testing.T) { - testUpdateJob(t, testapi.Extensions, extensions.GroupName) - testUpdateJob(t, testapi.Batch, batch.GroupName) -} - -func testUpdateJobStatus(t *testing.T, group testapi.TestGroup, resourceGroup string) { - ns := api.NamespaceDefault - requestJob := &batch.Job{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - ResourceVersion: "1", - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: group.ResourcePath(getJobsResourceName(), ns, "foo") + "/status", - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &batch.Job{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: batch.JobSpec{ - Template: api.PodTemplateSpec{}, - }, - Status: batch.JobStatus{ - Active: 1, - }, - }, - }, - ResourceGroup: resourceGroup, - } - receivedJob, err := getJobClient(t, c, ns, resourceGroup).UpdateStatus(requestJob) - defer c.Close() - c.Validate(t, receivedJob, err) -} - -func TestUpdateJobStatus(t *testing.T) { - testUpdateJobStatus(t, testapi.Extensions, extensions.GroupName) - testUpdateJobStatus(t, testapi.Batch, batch.GroupName) -} - -func testDeleteJob(t *testing.T, group testapi.TestGroup, resourceGroup string) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{ - Method: "DELETE", - Path: group.ResourcePath(getJobsResourceName(), ns, "foo"), - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{StatusCode: 200}, - ResourceGroup: resourceGroup, - } - err := getJobClient(t, c, ns, resourceGroup).Delete("foo", nil) - defer c.Close() - c.Validate(t, nil, err) -} - -func TestDeleteJob(t *testing.T) { - testDeleteJob(t, testapi.Extensions, extensions.GroupName) - testDeleteJob(t, testapi.Batch, batch.GroupName) -} - -func testCreateJob(t *testing.T, group testapi.TestGroup, resourceGroup string) { - ns := api.NamespaceDefault - requestJob := &batch.Job{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: group.ResourcePath(getJobsResourceName(), ns, ""), - Body: requestJob, - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &batch.Job{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: batch.JobSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - ResourceGroup: resourceGroup, - } - receivedJob, err := getJobClient(t, c, ns, resourceGroup).Create(requestJob) - defer c.Close() - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - c.Validate(t, receivedJob, err) -} - -func TestCreateJob(t *testing.T) { - testCreateJob(t, testapi.Extensions, extensions.GroupName) - testCreateJob(t, testapi.Batch, batch.GroupName) -} diff --git a/pkg/client/unversioned/limit_ranges.go b/pkg/client/unversioned/limit_ranges.go deleted file mode 100644 index 914a049f44673..0000000000000 --- a/pkg/client/unversioned/limit_ranges.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// LimitRangesNamespacer has methods to work with LimitRange resources in a namespace -type LimitRangesNamespacer interface { - LimitRanges(namespace string) LimitRangeInterface -} - -// LimitRangeInterface has methods to work with LimitRange resources. -type LimitRangeInterface interface { - List(opts api.ListOptions) (*api.LimitRangeList, error) - Get(name string) (*api.LimitRange, error) - Delete(name string) error - Create(limitRange *api.LimitRange) (*api.LimitRange, error) - Update(limitRange *api.LimitRange) (*api.LimitRange, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// limitRanges implements LimitRangesNamespacer interface -type limitRanges struct { - r *Client - ns string -} - -// newLimitRanges returns a limitRanges -func newLimitRanges(c *Client, namespace string) *limitRanges { - return &limitRanges{ - r: c, - ns: namespace, - } -} - -// List takes a selector, and returns the list of limitRanges that match that selector. -func (c *limitRanges) List(opts api.ListOptions) (result *api.LimitRangeList, err error) { - result = &api.LimitRangeList{} - err = c.r.Get().Namespace(c.ns).Resource("limitRanges").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get takes the name of the limitRange, and returns the corresponding Pod object, and an error if it occurs -func (c *limitRanges) Get(name string) (result *api.LimitRange, err error) { - result = &api.LimitRange{} - err = c.r.Get().Namespace(c.ns).Resource("limitRanges").Name(name).Do().Into(result) - return -} - -// Delete takes the name of the limitRange, and returns an error if one occurs -func (c *limitRanges) Delete(name string) error { - return c.r.Delete().Namespace(c.ns).Resource("limitRanges").Name(name).Do().Error() -} - -// Create takes the representation of a limitRange. Returns the server's representation of the limitRange, and an error, if it occurs. -func (c *limitRanges) Create(limitRange *api.LimitRange) (result *api.LimitRange, err error) { - result = &api.LimitRange{} - err = c.r.Post().Namespace(c.ns).Resource("limitRanges").Body(limitRange).Do().Into(result) - return -} - -// Update takes the representation of a limitRange to update. Returns the server's representation of the limitRange, and an error, if it occurs. -func (c *limitRanges) Update(limitRange *api.LimitRange) (result *api.LimitRange, err error) { - result = &api.LimitRange{} - err = c.r.Put().Namespace(c.ns).Resource("limitRanges").Name(limitRange.Name).Body(limitRange).Do().Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested resource -func (c *limitRanges) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("limitRanges"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/limit_ranges_test.go b/pkg/client/unversioned/limit_ranges_test.go deleted file mode 100644 index 47995e6c974aa..0000000000000 --- a/pkg/client/unversioned/limit_ranges_test.go +++ /dev/null @@ -1,185 +0,0 @@ -/* -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 unversioned_test - -import ( - "net/url" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/resource" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getLimitRangesResourceName() string { - return "limitranges" -} - -func TestLimitRangeCreate(t *testing.T) { - ns := api.NamespaceDefault - limitRange := &api.LimitRange{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - }, - Spec: api.LimitRangeSpec{ - Limits: []api.LimitRangeItem{ - { - Type: api.LimitTypePod, - Max: api.ResourceList{ - api.ResourceCPU: resource.MustParse("100"), - api.ResourceMemory: resource.MustParse("10000"), - }, - Min: api.ResourceList{ - api.ResourceCPU: resource.MustParse("0"), - api.ResourceMemory: resource.MustParse("100"), - }, - }, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Default.ResourcePath(getLimitRangesResourceName(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: limitRange, - }, - Response: simple.Response{StatusCode: 200, Body: limitRange}, - } - - response, err := c.Setup(t).LimitRanges(ns).Create(limitRange) - defer c.Close() - c.Validate(t, response, err) -} - -func TestLimitRangeGet(t *testing.T) { - ns := api.NamespaceDefault - limitRange := &api.LimitRange{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - }, - Spec: api.LimitRangeSpec{ - Limits: []api.LimitRangeItem{ - { - Type: api.LimitTypePod, - Max: api.ResourceList{ - api.ResourceCPU: resource.MustParse("100"), - api.ResourceMemory: resource.MustParse("10000"), - }, - Min: api.ResourceList{ - api.ResourceCPU: resource.MustParse("0"), - api.ResourceMemory: resource.MustParse("100"), - }, - }, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getLimitRangesResourceName(), ns, "abc"), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: limitRange}, - } - - response, err := c.Setup(t).LimitRanges(ns).Get("abc") - defer c.Close() - c.Validate(t, response, err) -} - -func TestLimitRangeList(t *testing.T) { - ns := api.NamespaceDefault - - limitRangeList := &api.LimitRangeList{ - Items: []api.LimitRange{ - { - ObjectMeta: api.ObjectMeta{Name: "foo"}, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getLimitRangesResourceName(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: limitRangeList}, - } - response, err := c.Setup(t).LimitRanges(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, response, err) -} - -func TestLimitRangeUpdate(t *testing.T) { - ns := api.NamespaceDefault - limitRange := &api.LimitRange{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - ResourceVersion: "1", - }, - Spec: api.LimitRangeSpec{ - Limits: []api.LimitRangeItem{ - { - Type: api.LimitTypePod, - Max: api.ResourceList{ - api.ResourceCPU: resource.MustParse("100"), - api.ResourceMemory: resource.MustParse("10000"), - }, - Min: api.ResourceList{ - api.ResourceCPU: resource.MustParse("0"), - api.ResourceMemory: resource.MustParse("100"), - }, - }, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Default.ResourcePath(getLimitRangesResourceName(), ns, "abc"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: limitRange}, - } - response, err := c.Setup(t).LimitRanges(ns).Update(limitRange) - defer c.Close() - c.Validate(t, response, err) -} - -func TestLimitRangeDelete(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Default.ResourcePath(getLimitRangesResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).LimitRanges(ns).Delete("foo") - defer c.Close() - c.Validate(t, nil, err) -} - -func TestLimitRangeWatch(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePathWithPrefix("watch", getLimitRangesResourceName(), "", ""), - Query: url.Values{"resourceVersion": []string{}}}, - Response: simple.Response{StatusCode: 200}, - } - _, err := c.Setup(t).LimitRanges(api.NamespaceAll).Watch(api.ListOptions{}) - defer c.Close() - c.Validate(t, nil, err) -} diff --git a/pkg/client/unversioned/namespaces.go b/pkg/client/unversioned/namespaces.go deleted file mode 100644 index b4a38361ca67c..0000000000000 --- a/pkg/client/unversioned/namespaces.go +++ /dev/null @@ -1,116 +0,0 @@ -/* -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 unversioned - -import ( - "fmt" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -type NamespacesInterface interface { - Namespaces() NamespaceInterface -} - -type NamespaceInterface interface { - Create(item *api.Namespace) (*api.Namespace, error) - Get(name string) (result *api.Namespace, err error) - List(opts api.ListOptions) (*api.NamespaceList, error) - Delete(name string) error - Update(item *api.Namespace) (*api.Namespace, error) - Watch(opts api.ListOptions) (watch.Interface, error) - Finalize(item *api.Namespace) (*api.Namespace, error) - Status(item *api.Namespace) (*api.Namespace, error) -} - -// namespaces implements NamespacesInterface -type namespaces struct { - r *Client -} - -// newNamespaces returns a namespaces object. -func newNamespaces(c *Client) *namespaces { - return &namespaces{r: c} -} - -// Create creates a new namespace. -func (c *namespaces) Create(namespace *api.Namespace) (*api.Namespace, error) { - result := &api.Namespace{} - err := c.r.Post().Resource("namespaces").Body(namespace).Do().Into(result) - return result, err -} - -// List lists all the namespaces in the cluster. -func (c *namespaces) List(opts api.ListOptions) (*api.NamespaceList, error) { - result := &api.NamespaceList{} - err := c.r.Get(). - Resource("namespaces"). - VersionedParams(&opts, api.ParameterCodec). - Do().Into(result) - return result, err -} - -// Update takes the representation of a namespace to update. Returns the server's representation of the namespace, and an error, if it occurs. -func (c *namespaces) Update(namespace *api.Namespace) (result *api.Namespace, err error) { - result = &api.Namespace{} - err = c.r.Put().Resource("namespaces").Name(namespace.Name).Body(namespace).Do().Into(result) - return -} - -// Finalize takes the representation of a namespace to update. Returns the server's representation of the namespace, and an error, if it occurs. -func (c *namespaces) Finalize(namespace *api.Namespace) (result *api.Namespace, err error) { - result = &api.Namespace{} - if len(namespace.ResourceVersion) == 0 { - err = fmt.Errorf("invalid update object, missing resource version: %v", namespace) - return - } - err = c.r.Put().Resource("namespaces").Name(namespace.Name).SubResource("finalize").Body(namespace).Do().Into(result) - return -} - -// Status takes the representation of a namespace to update. Returns the server's representation of the namespace, and an error, if it occurs. -func (c *namespaces) Status(namespace *api.Namespace) (result *api.Namespace, err error) { - result = &api.Namespace{} - if len(namespace.ResourceVersion) == 0 { - err = fmt.Errorf("invalid update object, missing resource version: %v", namespace) - return - } - err = c.r.Put().Resource("namespaces").Name(namespace.Name).SubResource("status").Body(namespace).Do().Into(result) - return -} - -// Get gets an existing namespace -func (c *namespaces) Get(name string) (*api.Namespace, error) { - result := &api.Namespace{} - err := c.r.Get().Resource("namespaces").Name(name).Do().Into(result) - return result, err -} - -// Delete deletes an existing namespace. -func (c *namespaces) Delete(name string) error { - return c.r.Delete().Resource("namespaces").Name(name).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested namespaces. -func (c *namespaces) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Resource("namespaces"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/namespaces_test.go b/pkg/client/unversioned/namespaces_test.go deleted file mode 100644 index ce4db7f990e9d..0000000000000 --- a/pkg/client/unversioned/namespaces_test.go +++ /dev/null @@ -1,185 +0,0 @@ -/* -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 unversioned_test - -import ( - "net/url" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func TestNamespaceCreate(t *testing.T) { - // we create a namespace relative to another namespace - namespace := &api.Namespace{ - ObjectMeta: api.ObjectMeta{Name: "foo"}, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Default.ResourcePath("namespaces", "", ""), - Body: namespace, - }, - Response: simple.Response{StatusCode: 200, Body: namespace}, - } - - // from the source ns, provision a new global namespace "foo" - response, err := c.Setup(t).Namespaces().Create(namespace) - defer c.Close() - - if err != nil { - t.Errorf("%#v should be nil.", err) - } - - if e, a := response.Name, namespace.Name; e != a { - t.Errorf("%#v != %#v.", e, a) - } -} - -func TestNamespaceGet(t *testing.T) { - namespace := &api.Namespace{ - ObjectMeta: api.ObjectMeta{Name: "foo"}, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath("namespaces", "", "foo"), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: namespace}, - } - - response, err := c.Setup(t).Namespaces().Get("foo") - defer c.Close() - - if err != nil { - t.Errorf("%#v should be nil.", err) - } - - if e, r := response.Name, namespace.Name; e != r { - t.Errorf("%#v != %#v.", e, r) - } -} - -func TestNamespaceList(t *testing.T) { - namespaceList := &api.NamespaceList{ - Items: []api.Namespace{ - { - ObjectMeta: api.ObjectMeta{Name: "foo"}, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath("namespaces", "", ""), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: namespaceList}, - } - response, err := c.Setup(t).Namespaces().List(api.ListOptions{}) - defer c.Close() - - if err != nil { - t.Errorf("%#v should be nil.", err) - } - - if len(response.Items) != 1 { - t.Errorf("%#v response.Items should have len 1.", response.Items) - } - - responseNamespace := response.Items[0] - if e, r := responseNamespace.Name, "foo"; e != r { - t.Errorf("%#v != %#v.", e, r) - } -} - -func TestNamespaceUpdate(t *testing.T) { - requestNamespace := &api.Namespace{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - ResourceVersion: "1", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: api.NamespaceSpec{ - Finalizers: []api.FinalizerName{api.FinalizerKubernetes}, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Default.ResourcePath("namespaces", "", "foo")}, - Response: simple.Response{StatusCode: 200, Body: requestNamespace}, - } - receivedNamespace, err := c.Setup(t).Namespaces().Update(requestNamespace) - defer c.Close() - c.Validate(t, receivedNamespace, err) -} - -func TestNamespaceFinalize(t *testing.T) { - requestNamespace := &api.Namespace{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - ResourceVersion: "1", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: api.NamespaceSpec{ - Finalizers: []api.FinalizerName{api.FinalizerKubernetes}, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Default.ResourcePath("namespaces", "", "foo") + "/finalize", - }, - Response: simple.Response{StatusCode: 200, Body: requestNamespace}, - } - receivedNamespace, err := c.Setup(t).Namespaces().Finalize(requestNamespace) - defer c.Close() - c.Validate(t, receivedNamespace, err) -} - -func TestNamespaceDelete(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Default.ResourcePath("namespaces", "", "foo")}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).Namespaces().Delete("foo") - defer c.Close() - c.Validate(t, nil, err) -} - -func TestNamespaceWatch(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePathWithPrefix("watch", "namespaces", "", ""), - Query: url.Values{"resourceVersion": []string{}}}, - Response: simple.Response{StatusCode: 200}, - } - _, err := c.Setup(t).Namespaces().Watch(api.ListOptions{}) - defer c.Close() - c.Validate(t, nil, err) -} diff --git a/pkg/client/unversioned/network_policys.go b/pkg/client/unversioned/network_policys.go deleted file mode 100644 index 3e3f61045d713..0000000000000 --- a/pkg/client/unversioned/network_policys.go +++ /dev/null @@ -1,92 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/watch" -) - -// NetworkPolicyNamespacer has methods to work with NetworkPolicy resources in a namespace -type NetworkPolicyNamespacer interface { - NetworkPolicies(namespace string) NetworkPolicyInterface -} - -// NetworkPolicyInterface exposes methods to work on NetworkPolicy resources. -type NetworkPolicyInterface interface { - List(opts api.ListOptions) (*extensions.NetworkPolicyList, error) - Get(name string) (*extensions.NetworkPolicy, error) - Create(networkPolicy *extensions.NetworkPolicy) (*extensions.NetworkPolicy, error) - Update(networkPolicy *extensions.NetworkPolicy) (*extensions.NetworkPolicy, error) - Delete(name string, options *api.DeleteOptions) error - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// NetworkPolicies implements NetworkPolicyNamespacer interface -type NetworkPolicies struct { - r *ExtensionsClient - ns string -} - -// newNetworkPolicies returns a NetworkPolicies -func newNetworkPolicies(c *ExtensionsClient, namespace string) *NetworkPolicies { - return &NetworkPolicies{c, namespace} -} - -// List returns a list of networkPolicy that match the label and field selectors. -func (c *NetworkPolicies) List(opts api.ListOptions) (result *extensions.NetworkPolicyList, err error) { - result = &extensions.NetworkPolicyList{} - err = c.r.Get().Namespace(c.ns).Resource("networkpolicies").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get returns information about a particular networkPolicy. -func (c *NetworkPolicies) Get(name string) (result *extensions.NetworkPolicy, err error) { - result = &extensions.NetworkPolicy{} - err = c.r.Get().Namespace(c.ns).Resource("networkpolicies").Name(name).Do().Into(result) - return -} - -// Create creates a new networkPolicy. -func (c *NetworkPolicies) Create(networkPolicy *extensions.NetworkPolicy) (result *extensions.NetworkPolicy, err error) { - result = &extensions.NetworkPolicy{} - err = c.r.Post().Namespace(c.ns).Resource("networkpolicies").Body(networkPolicy).Do().Into(result) - return -} - -// Update updates an existing networkPolicy. -func (c *NetworkPolicies) Update(networkPolicy *extensions.NetworkPolicy) (result *extensions.NetworkPolicy, err error) { - result = &extensions.NetworkPolicy{} - err = c.r.Put().Namespace(c.ns).Resource("networkpolicies").Name(networkPolicy.Name).Body(networkPolicy).Do().Into(result) - return -} - -// Delete deletes a networkPolicy, returns error if one occurs. -func (c *NetworkPolicies) Delete(name string, options *api.DeleteOptions) (err error) { - return c.r.Delete().Namespace(c.ns).Resource("networkpolicies").Name(name).Body(options).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested networkPolicy. -func (c *NetworkPolicies) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("networkpolicies"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/nodes.go b/pkg/client/unversioned/nodes.go deleted file mode 100644 index 15a7db2ad188c..0000000000000 --- a/pkg/client/unversioned/nodes.go +++ /dev/null @@ -1,111 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -type NodesInterface interface { - Nodes() NodeInterface -} - -type NodeInterface interface { - Get(name string) (result *api.Node, err error) - Create(node *api.Node) (*api.Node, error) - List(opts api.ListOptions) (*api.NodeList, error) - Delete(name string) error - DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error - Update(*api.Node) (*api.Node, error) - UpdateStatus(*api.Node) (*api.Node, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// nodes implements NodesInterface -type nodes struct { - r *Client -} - -// newNodes returns a nodes object. -func newNodes(c *Client) *nodes { - return &nodes{c} -} - -// resourceName returns node's URL resource name. -func (c *nodes) resourceName() string { - return "nodes" -} - -// Create creates a new node. -func (c *nodes) Create(node *api.Node) (*api.Node, error) { - result := &api.Node{} - err := c.r.Post().Resource(c.resourceName()).Body(node).Do().Into(result) - return result, err -} - -// List takes a selector, and returns the list of nodes that match that selector in the cluster. -func (c *nodes) List(opts api.ListOptions) (*api.NodeList, error) { - result := &api.NodeList{} - err := c.r.Get().Resource(c.resourceName()).VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return result, err -} - -// Get gets an existing node. -func (c *nodes) Get(name string) (*api.Node, error) { - result := &api.Node{} - err := c.r.Get().Resource(c.resourceName()).Name(name).Do().Into(result) - return result, err -} - -// Delete deletes an existing node. -func (c *nodes) Delete(name string) error { - return c.r.Delete().Resource(c.resourceName()).Name(name).Do().Error() -} - -// DeleteCollection deletes a collection of nodes. -func (c *nodes) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { - return c.r.Delete(). - Resource(c.resourceName()). - VersionedParams(&listOptions, api.ParameterCodec). - Body(options). - Do(). - Error() -} - -// Update updates an existing node. -func (c *nodes) Update(node *api.Node) (*api.Node, error) { - result := &api.Node{} - err := c.r.Put().Resource(c.resourceName()).Name(node.Name).Body(node).Do().Into(result) - return result, err -} - -func (c *nodes) UpdateStatus(node *api.Node) (*api.Node, error) { - result := &api.Node{} - err := c.r.Put().Resource(c.resourceName()).Name(node.Name).SubResource("status").Body(node).Do().Into(result) - return result, err -} - -// Watch returns a watch.Interface that watches the requested nodes. -func (c *nodes) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(api.NamespaceAll). - Resource(c.resourceName()). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/nodes_test.go b/pkg/client/unversioned/nodes_test.go deleted file mode 100644 index df6b5369431d3..0000000000000 --- a/pkg/client/unversioned/nodes_test.go +++ /dev/null @@ -1,174 +0,0 @@ -/* -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 unversioned_test - -import ( - "net/url" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/resource" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/apimachinery/registered" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" - "k8s.io/kubernetes/pkg/labels" -) - -func getNodesResourceName() string { - return "nodes" -} - -func TestListNodes(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getNodesResourceName(), "", ""), - }, - Response: simple.Response{StatusCode: 200, Body: &api.NodeList{ListMeta: unversioned.ListMeta{ResourceVersion: "1"}}}, - } - response, err := c.Setup(t).Nodes().List(api.ListOptions{}) - defer c.Close() - c.Validate(t, response, err) -} - -func TestListNodesLabels(t *testing.T) { - labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(registered.GroupOrDie(api.GroupName).GroupVersion.String()) - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getNodesResourceName(), "", ""), - Query: simple.BuildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})}, - Response: simple.Response{ - StatusCode: 200, - Body: &api.NodeList{ - Items: []api.Node{ - { - ObjectMeta: api.ObjectMeta{ - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - }, - }, - }, - }, - } - c.Setup(t) - defer c.Close() - c.QueryValidator[labelSelectorQueryParamName] = simple.ValidateLabels - selector := labels.Set{"foo": "bar", "name": "baz"}.AsSelector() - options := api.ListOptions{LabelSelector: selector} - receivedNodeList, err := c.Nodes().List(options) - c.Validate(t, receivedNodeList, err) -} - -func TestGetNode(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getNodesResourceName(), "", "1"), - }, - Response: simple.Response{StatusCode: 200, Body: &api.Node{ObjectMeta: api.ObjectMeta{Name: "node-1"}}}, - } - response, err := c.Setup(t).Nodes().Get("1") - defer c.Close() - c.Validate(t, response, err) -} - -func TestGetNodeWithNoName(t *testing.T) { - c := &simple.Client{Error: true} - receivedNode, err := c.Setup(t).Nodes().Get("") - defer c.Close() - if (err != nil) && (err.Error() != simple.NameRequiredError) { - t.Errorf("Expected error: %v, but got %v", simple.NameRequiredError, err) - } - - c.Validate(t, receivedNode, err) -} - -func TestCreateNode(t *testing.T) { - requestNode := &api.Node{ - ObjectMeta: api.ObjectMeta{ - Name: "node-1", - }, - Status: api.NodeStatus{ - Capacity: api.ResourceList{ - api.ResourceCPU: resource.MustParse("1000m"), - api.ResourceMemory: resource.MustParse("1Mi"), - }, - }, - Spec: api.NodeSpec{ - Unschedulable: false, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Default.ResourcePath(getNodesResourceName(), "", ""), - Body: requestNode}, - Response: simple.Response{ - StatusCode: 200, - Body: requestNode, - }, - } - receivedNode, err := c.Setup(t).Nodes().Create(requestNode) - defer c.Close() - c.Validate(t, receivedNode, err) -} - -func TestDeleteNode(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "DELETE", - Path: testapi.Default.ResourcePath(getNodesResourceName(), "", "foo"), - }, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).Nodes().Delete("foo") - defer c.Close() - c.Validate(t, nil, err) -} - -func TestUpdateNode(t *testing.T) { - requestNode := &api.Node{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - ResourceVersion: "1", - }, - Status: api.NodeStatus{ - Capacity: api.ResourceList{ - api.ResourceCPU: resource.MustParse("1000m"), - api.ResourceMemory: resource.MustParse("1Mi"), - }, - }, - Spec: api.NodeSpec{ - Unschedulable: true, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Default.ResourcePath(getNodesResourceName(), "", "foo"), - }, - Response: simple.Response{StatusCode: 200, Body: requestNode}, - } - response, err := c.Setup(t).Nodes().Update(requestNode) - defer c.Close() - c.Validate(t, response, err) -} diff --git a/pkg/client/unversioned/persistentvolume_test.go b/pkg/client/unversioned/persistentvolume_test.go deleted file mode 100644 index 20832461b5e99..0000000000000 --- a/pkg/client/unversioned/persistentvolume_test.go +++ /dev/null @@ -1,191 +0,0 @@ -/* -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 unversioned_test - -import ( - "net/url" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/resource" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getPersistentVolumesResoureName() string { - return "persistentvolumes" -} - -func TestPersistentVolumeCreate(t *testing.T) { - pv := &api.PersistentVolume{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - }, - Spec: api.PersistentVolumeSpec{ - Capacity: api.ResourceList{ - api.ResourceName(api.ResourceStorage): resource.MustParse("10G"), - }, - PersistentVolumeSource: api.PersistentVolumeSource{ - HostPath: &api.HostPathVolumeSource{Path: "/foo"}, - }, - }, - } - - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Default.ResourcePath(getPersistentVolumesResoureName(), "", ""), - Query: simple.BuildQueryValues(nil), - Body: pv, - }, - Response: simple.Response{StatusCode: 200, Body: pv}, - } - - response, err := c.Setup(t).PersistentVolumes().Create(pv) - defer c.Close() - c.Validate(t, response, err) -} - -func TestPersistentVolumeGet(t *testing.T) { - persistentVolume := &api.PersistentVolume{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: "foo", - }, - Spec: api.PersistentVolumeSpec{ - Capacity: api.ResourceList{ - api.ResourceName(api.ResourceStorage): resource.MustParse("10G"), - }, - PersistentVolumeSource: api.PersistentVolumeSource{ - HostPath: &api.HostPathVolumeSource{Path: "/foo"}, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getPersistentVolumesResoureName(), "", "abc"), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: persistentVolume}, - } - - response, err := c.Setup(t).PersistentVolumes().Get("abc") - defer c.Close() - c.Validate(t, response, err) -} - -func TestPersistentVolumeList(t *testing.T) { - persistentVolumeList := &api.PersistentVolumeList{ - Items: []api.PersistentVolume{ - { - ObjectMeta: api.ObjectMeta{Name: "foo"}, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getPersistentVolumesResoureName(), "", ""), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: persistentVolumeList}, - } - response, err := c.Setup(t).PersistentVolumes().List(api.ListOptions{}) - defer c.Close() - c.Validate(t, response, err) -} - -func TestPersistentVolumeUpdate(t *testing.T) { - persistentVolume := &api.PersistentVolume{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - ResourceVersion: "1", - }, - Spec: api.PersistentVolumeSpec{ - Capacity: api.ResourceList{ - api.ResourceName(api.ResourceStorage): resource.MustParse("10G"), - }, - PersistentVolumeSource: api.PersistentVolumeSource{ - HostPath: &api.HostPathVolumeSource{Path: "/foo"}, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Default.ResourcePath(getPersistentVolumesResoureName(), "", "abc"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: persistentVolume}, - } - response, err := c.Setup(t).PersistentVolumes().Update(persistentVolume) - defer c.Close() - c.Validate(t, response, err) -} - -func TestPersistentVolumeStatusUpdate(t *testing.T) { - persistentVolume := &api.PersistentVolume{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - ResourceVersion: "1", - }, - Spec: api.PersistentVolumeSpec{ - Capacity: api.ResourceList{ - api.ResourceName(api.ResourceStorage): resource.MustParse("10G"), - }, - PersistentVolumeSource: api.PersistentVolumeSource{ - HostPath: &api.HostPathVolumeSource{Path: "/foo"}, - }, - }, - Status: api.PersistentVolumeStatus{ - Phase: api.VolumeBound, - Message: "foo", - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Default.ResourcePath(getPersistentVolumesResoureName(), "", "abc") + "/status", - Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: persistentVolume}, - } - response, err := c.Setup(t).PersistentVolumes().UpdateStatus(persistentVolume) - defer c.Close() - c.Validate(t, response, err) -} - -func TestPersistentVolumeDelete(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Default.ResourcePath(getPersistentVolumesResoureName(), "", "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).PersistentVolumes().Delete("foo") - defer c.Close() - c.Validate(t, nil, err) -} - -func TestPersistentVolumeWatch(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePathWithPrefix("watch", getPersistentVolumesResoureName(), "", ""), - Query: url.Values{"resourceVersion": []string{}}}, - Response: simple.Response{StatusCode: 200}, - } - _, err := c.Setup(t).PersistentVolumes().Watch(api.ListOptions{}) - defer c.Close() - c.Validate(t, nil, err) -} diff --git a/pkg/client/unversioned/persistentvolumeclaim.go b/pkg/client/unversioned/persistentvolumeclaim.go deleted file mode 100644 index 4ea3a95a761b4..0000000000000 --- a/pkg/client/unversioned/persistentvolumeclaim.go +++ /dev/null @@ -1,99 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// PersistentVolumeClaimsNamespacer has methods to work with PersistentVolumeClaim resources in a namespace -type PersistentVolumeClaimsNamespacer interface { - PersistentVolumeClaims(namespace string) PersistentVolumeClaimInterface -} - -// PersistentVolumeClaimInterface has methods to work with PersistentVolumeClaim resources. -type PersistentVolumeClaimInterface interface { - List(opts api.ListOptions) (*api.PersistentVolumeClaimList, error) - Get(name string) (*api.PersistentVolumeClaim, error) - Create(claim *api.PersistentVolumeClaim) (*api.PersistentVolumeClaim, error) - Update(claim *api.PersistentVolumeClaim) (*api.PersistentVolumeClaim, error) - UpdateStatus(claim *api.PersistentVolumeClaim) (*api.PersistentVolumeClaim, error) - Delete(name string) error - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// persistentVolumeClaims implements PersistentVolumeClaimsNamespacer interface -type persistentVolumeClaims struct { - client *Client - namespace string -} - -// newPersistentVolumeClaims returns a PodsClient -func newPersistentVolumeClaims(c *Client, namespace string) *persistentVolumeClaims { - return &persistentVolumeClaims{c, namespace} -} - -func (c *persistentVolumeClaims) List(opts api.ListOptions) (result *api.PersistentVolumeClaimList, err error) { - result = &api.PersistentVolumeClaimList{} - - err = c.client.Get(). - Namespace(c.namespace). - Resource("persistentVolumeClaims"). - VersionedParams(&opts, api.ParameterCodec). - Do(). - Into(result) - - return result, err -} - -func (c *persistentVolumeClaims) Get(name string) (result *api.PersistentVolumeClaim, err error) { - result = &api.PersistentVolumeClaim{} - err = c.client.Get().Namespace(c.namespace).Resource("persistentVolumeClaims").Name(name).Do().Into(result) - return -} - -func (c *persistentVolumeClaims) Create(claim *api.PersistentVolumeClaim) (result *api.PersistentVolumeClaim, err error) { - result = &api.PersistentVolumeClaim{} - err = c.client.Post().Namespace(c.namespace).Resource("persistentVolumeClaims").Body(claim).Do().Into(result) - return -} - -func (c *persistentVolumeClaims) Update(claim *api.PersistentVolumeClaim) (result *api.PersistentVolumeClaim, err error) { - result = &api.PersistentVolumeClaim{} - err = c.client.Put().Namespace(c.namespace).Resource("persistentVolumeClaims").Name(claim.Name).Body(claim).Do().Into(result) - return -} - -func (c *persistentVolumeClaims) UpdateStatus(claim *api.PersistentVolumeClaim) (result *api.PersistentVolumeClaim, err error) { - result = &api.PersistentVolumeClaim{} - err = c.client.Put().Namespace(c.namespace).Resource("persistentVolumeClaims").Name(claim.Name).SubResource("status").Body(claim).Do().Into(result) - return -} - -func (c *persistentVolumeClaims) Delete(name string) error { - return c.client.Delete().Namespace(c.namespace).Resource("persistentVolumeClaims").Name(name).Do().Error() -} - -func (c *persistentVolumeClaims) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.client.Get(). - Prefix("watch"). - Namespace(c.namespace). - Resource("persistentVolumeClaims"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/persistentvolumeclaim_test.go b/pkg/client/unversioned/persistentvolumeclaim_test.go deleted file mode 100644 index 18a9b9d89fe5c..0000000000000 --- a/pkg/client/unversioned/persistentvolumeclaim_test.go +++ /dev/null @@ -1,208 +0,0 @@ -/* -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 unversioned_test - -import ( - "net/url" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/resource" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getPersistentVolumeClaimsResoureName() string { - return "persistentvolumeclaims" -} - -func TestPersistentVolumeClaimCreate(t *testing.T) { - ns := api.NamespaceDefault - pv := &api.PersistentVolumeClaim{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - }, - Spec: api.PersistentVolumeClaimSpec{ - AccessModes: []api.PersistentVolumeAccessMode{ - api.ReadWriteOnce, - api.ReadOnlyMany, - }, - Resources: api.ResourceRequirements{ - Requests: api.ResourceList{ - api.ResourceName(api.ResourceStorage): resource.MustParse("10G"), - }, - }, - }, - } - - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Default.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: pv, - }, - Response: simple.Response{StatusCode: 200, Body: pv}, - } - - response, err := c.Setup(t).PersistentVolumeClaims(ns).Create(pv) - defer c.Close() - c.Validate(t, response, err) -} - -func TestPersistentVolumeClaimGet(t *testing.T) { - ns := api.NamespaceDefault - persistentVolumeClaim := &api.PersistentVolumeClaim{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: "foo", - }, - Spec: api.PersistentVolumeClaimSpec{ - AccessModes: []api.PersistentVolumeAccessMode{ - api.ReadWriteOnce, - api.ReadOnlyMany, - }, - Resources: api.ResourceRequirements{ - Requests: api.ResourceList{ - api.ResourceName(api.ResourceStorage): resource.MustParse("10G"), - }, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, "abc"), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: persistentVolumeClaim}, - } - - response, err := c.Setup(t).PersistentVolumeClaims(ns).Get("abc") - defer c.Close() - c.Validate(t, response, err) -} - -func TestPersistentVolumeClaimList(t *testing.T) { - ns := api.NamespaceDefault - persistentVolumeList := &api.PersistentVolumeClaimList{ - Items: []api.PersistentVolumeClaim{ - { - ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "ns"}, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: persistentVolumeList}, - } - response, err := c.Setup(t).PersistentVolumeClaims(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, response, err) -} - -func TestPersistentVolumeClaimUpdate(t *testing.T) { - ns := api.NamespaceDefault - persistentVolumeClaim := &api.PersistentVolumeClaim{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - ResourceVersion: "1", - }, - Spec: api.PersistentVolumeClaimSpec{ - AccessModes: []api.PersistentVolumeAccessMode{ - api.ReadWriteOnce, - api.ReadOnlyMany, - }, - Resources: api.ResourceRequirements{ - Requests: api.ResourceList{ - api.ResourceName(api.ResourceStorage): resource.MustParse("10G"), - }, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Default.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, "abc"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: persistentVolumeClaim}, - } - response, err := c.Setup(t).PersistentVolumeClaims(ns).Update(persistentVolumeClaim) - defer c.Close() - c.Validate(t, response, err) -} - -func TestPersistentVolumeClaimStatusUpdate(t *testing.T) { - ns := api.NamespaceDefault - persistentVolumeClaim := &api.PersistentVolumeClaim{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - ResourceVersion: "1", - }, - Spec: api.PersistentVolumeClaimSpec{ - AccessModes: []api.PersistentVolumeAccessMode{ - api.ReadWriteOnce, - api.ReadOnlyMany, - }, - Resources: api.ResourceRequirements{ - Requests: api.ResourceList{ - api.ResourceName(api.ResourceStorage): resource.MustParse("10G"), - }, - }, - }, - Status: api.PersistentVolumeClaimStatus{ - Phase: api.ClaimBound, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Default.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, "abc") + "/status", - Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: persistentVolumeClaim}, - } - response, err := c.Setup(t).PersistentVolumeClaims(ns).UpdateStatus(persistentVolumeClaim) - defer c.Close() - c.Validate(t, response, err) -} - -func TestPersistentVolumeClaimDelete(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Default.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).PersistentVolumeClaims(ns).Delete("foo") - defer c.Close() - c.Validate(t, nil, err) -} - -func TestPersistentVolumeClaimWatch(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePathWithPrefix("watch", getPersistentVolumeClaimsResoureName(), "", ""), - Query: url.Values{"resourceVersion": []string{}}}, - Response: simple.Response{StatusCode: 200}, - } - _, err := c.Setup(t).PersistentVolumeClaims(api.NamespaceAll).Watch(api.ListOptions{}) - defer c.Close() - c.Validate(t, nil, err) -} diff --git a/pkg/client/unversioned/persistentvolumes.go b/pkg/client/unversioned/persistentvolumes.go deleted file mode 100644 index 5fce1f0a452bc..0000000000000 --- a/pkg/client/unversioned/persistentvolumes.go +++ /dev/null @@ -1,93 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -type PersistentVolumesInterface interface { - PersistentVolumes() PersistentVolumeInterface -} - -// PersistentVolumeInterface has methods to work with PersistentVolume resources. -type PersistentVolumeInterface interface { - List(opts api.ListOptions) (*api.PersistentVolumeList, error) - Get(name string) (*api.PersistentVolume, error) - Create(volume *api.PersistentVolume) (*api.PersistentVolume, error) - Update(volume *api.PersistentVolume) (*api.PersistentVolume, error) - UpdateStatus(persistentVolume *api.PersistentVolume) (*api.PersistentVolume, error) - Delete(name string) error - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// persistentVolumes implements PersistentVolumesInterface -type persistentVolumes struct { - client *Client -} - -func newPersistentVolumes(c *Client) *persistentVolumes { - return &persistentVolumes{c} -} - -func (c *persistentVolumes) List(opts api.ListOptions) (result *api.PersistentVolumeList, err error) { - result = &api.PersistentVolumeList{} - err = c.client.Get(). - Resource("persistentVolumes"). - VersionedParams(&opts, api.ParameterCodec). - Do(). - Into(result) - - return result, err -} - -func (c *persistentVolumes) Get(name string) (result *api.PersistentVolume, err error) { - result = &api.PersistentVolume{} - err = c.client.Get().Resource("persistentVolumes").Name(name).Do().Into(result) - return -} - -func (c *persistentVolumes) Create(volume *api.PersistentVolume) (result *api.PersistentVolume, err error) { - result = &api.PersistentVolume{} - err = c.client.Post().Resource("persistentVolumes").Body(volume).Do().Into(result) - return -} - -func (c *persistentVolumes) Update(volume *api.PersistentVolume) (result *api.PersistentVolume, err error) { - result = &api.PersistentVolume{} - err = c.client.Put().Resource("persistentVolumes").Name(volume.Name).Body(volume).Do().Into(result) - return -} - -func (c *persistentVolumes) UpdateStatus(volume *api.PersistentVolume) (result *api.PersistentVolume, err error) { - result = &api.PersistentVolume{} - err = c.client.Put().Resource("persistentVolumes").Name(volume.Name).SubResource("status").Body(volume).Do().Into(result) - return -} - -func (c *persistentVolumes) Delete(name string) error { - return c.client.Delete().Resource("persistentVolumes").Name(name).Do().Error() -} - -func (c *persistentVolumes) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.client.Get(). - Prefix("watch"). - Resource("persistentVolumes"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/pet_sets.go b/pkg/client/unversioned/pet_sets.go deleted file mode 100644 index 954efcd092230..0000000000000 --- a/pkg/client/unversioned/pet_sets.go +++ /dev/null @@ -1,100 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/apps" - "k8s.io/kubernetes/pkg/watch" -) - -// PetSetNamespacer has methods to work with PetSet resources in a namespace -type PetSetNamespacer interface { - PetSets(namespace string) PetSetInterface -} - -// PetSetInterface exposes methods to work on PetSet resources. -type PetSetInterface interface { - List(opts api.ListOptions) (*apps.PetSetList, error) - Get(name string) (*apps.PetSet, error) - Create(petSet *apps.PetSet) (*apps.PetSet, error) - Update(petSet *apps.PetSet) (*apps.PetSet, error) - Delete(name string, options *api.DeleteOptions) error - Watch(opts api.ListOptions) (watch.Interface, error) - UpdateStatus(petSet *apps.PetSet) (*apps.PetSet, error) -} - -// petSet implements PetSetNamespacer interface -type petSet struct { - r *AppsClient - ns string -} - -// newPetSet returns a petSet -func newPetSet(c *AppsClient, namespace string) *petSet { - return &petSet{c, namespace} -} - -// List returns a list of petSet that match the label and field selectors. -func (c *petSet) List(opts api.ListOptions) (result *apps.PetSetList, err error) { - result = &apps.PetSetList{} - err = c.r.Get().Namespace(c.ns).Resource("petsets").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get returns information about a particular petSet. -func (c *petSet) Get(name string) (result *apps.PetSet, err error) { - result = &apps.PetSet{} - err = c.r.Get().Namespace(c.ns).Resource("petsets").Name(name).Do().Into(result) - return -} - -// Create creates a new petSet. -func (c *petSet) Create(petSet *apps.PetSet) (result *apps.PetSet, err error) { - result = &apps.PetSet{} - err = c.r.Post().Namespace(c.ns).Resource("petsets").Body(petSet).Do().Into(result) - return -} - -// Update updates an existing petSet. -func (c *petSet) Update(petSet *apps.PetSet) (result *apps.PetSet, err error) { - result = &apps.PetSet{} - err = c.r.Put().Namespace(c.ns).Resource("petsets").Name(petSet.Name).Body(petSet).Do().Into(result) - return -} - -// Delete deletes a petSet, returns error if one occurs. -func (c *petSet) Delete(name string, options *api.DeleteOptions) (err error) { - return c.r.Delete().Namespace(c.ns).Resource("petsets").Name(name).Body(options).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested petSet. -func (c *petSet) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("petsets"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -// UpdateStatus takes the name of the petSet and the new status. Returns the server's representation of the petSet, and an error, if it occurs. -func (c *petSet) UpdateStatus(petSet *apps.PetSet) (result *apps.PetSet, err error) { - result = &apps.PetSet{} - err = c.r.Put().Namespace(c.ns).Resource("petsets").Name(petSet.Name).SubResource("status").Body(petSet).Do().Into(result) - return -} diff --git a/pkg/client/unversioned/pet_sets_test.go b/pkg/client/unversioned/pet_sets_test.go deleted file mode 100644 index fb00024e6e13c..0000000000000 --- a/pkg/client/unversioned/pet_sets_test.go +++ /dev/null @@ -1,165 +0,0 @@ -/* -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 unversioned_test - -import ( - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/apis/apps" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getPetSetResourceName() string { - return "petsets" -} - -func TestListPetSets(t *testing.T) { - ns := api.NamespaceAll - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Apps.ResourcePath(getPetSetResourceName(), ns, ""), - }, - Response: simple.Response{StatusCode: 200, - Body: &apps.PetSetList{ - Items: []apps.PetSet{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: apps.PetSetSpec{ - Replicas: 2, - Template: api.PodTemplateSpec{}, - }, - }, - }, - }, - }, - } - receivedRSList, err := c.Setup(t).Apps().PetSets(ns).List(api.ListOptions{}) - c.Validate(t, receivedRSList, err) -} - -func TestGetPetSet(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "GET", Path: testapi.Apps.ResourcePath(getPetSetResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &apps.PetSet{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: apps.PetSetSpec{ - Replicas: 2, - Template: api.PodTemplateSpec{}, - }, - }, - }, - } - receivedRS, err := c.Setup(t).Apps().PetSets(ns).Get("foo") - c.Validate(t, receivedRS, err) -} - -func TestGetPetSetWithNoName(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{Error: true} - receivedPod, err := c.Setup(t).Apps().PetSets(ns).Get("") - if (err != nil) && (err.Error() != simple.NameRequiredError) { - t.Errorf("Expected error: %v, but got %v", simple.NameRequiredError, err) - } - - c.Validate(t, receivedPod, err) -} - -func TestUpdatePetSet(t *testing.T) { - ns := api.NamespaceDefault - requestRS := &apps.PetSet{ - ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Apps.ResourcePath(getPetSetResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &apps.PetSet{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: apps.PetSetSpec{ - Replicas: 2, - Template: api.PodTemplateSpec{}, - }, - }, - }, - } - receivedRS, err := c.Setup(t).Apps().PetSets(ns).Update(requestRS) - c.Validate(t, receivedRS, err) -} - -func TestDeletePetSet(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Apps.ResourcePath(getPetSetResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).Apps().PetSets(ns).Delete("foo", nil) - c.Validate(t, nil, err) -} - -func TestCreatePetSet(t *testing.T) { - ns := api.NamespaceDefault - requestRS := &apps.PetSet{ - ObjectMeta: api.ObjectMeta{Name: "foo"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "POST", Path: testapi.Apps.ResourcePath(getPetSetResourceName(), ns, ""), Body: requestRS, Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &apps.PetSet{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: apps.PetSetSpec{ - Replicas: 2, - Template: api.PodTemplateSpec{}, - }, - }, - }, - } - receivedRS, err := c.Setup(t).Apps().PetSets(ns).Create(requestRS) - c.Validate(t, receivedRS, err) -} - -// TODO: Test Status actions. diff --git a/pkg/client/unversioned/pod_disruption_budgets.go b/pkg/client/unversioned/pod_disruption_budgets.go deleted file mode 100644 index 0239623a7bcbc..0000000000000 --- a/pkg/client/unversioned/pod_disruption_budgets.go +++ /dev/null @@ -1,100 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/policy" - "k8s.io/kubernetes/pkg/watch" -) - -// PodDisruptionBudgetNamespacer has methods to work with PodDisruptionBudget resources in a namespace -type PodDisruptionBudgetNamespacer interface { - PodDisruptionBudgets(namespace string) PodDisruptionBudgetInterface -} - -// PodDisruptionBudgetInterface exposes methods to work on PodDisruptionBudget resources. -type PodDisruptionBudgetInterface interface { - List(opts api.ListOptions) (*policy.PodDisruptionBudgetList, error) - Get(name string) (*policy.PodDisruptionBudget, error) - Create(podDisruptionBudget *policy.PodDisruptionBudget) (*policy.PodDisruptionBudget, error) - Update(podDisruptionBudget *policy.PodDisruptionBudget) (*policy.PodDisruptionBudget, error) - Delete(name string, options *api.DeleteOptions) error - Watch(opts api.ListOptions) (watch.Interface, error) - UpdateStatus(podDisruptionBudget *policy.PodDisruptionBudget) (*policy.PodDisruptionBudget, error) -} - -// podDisruptionBudget implements PodDisruptionBudgetNamespacer interface -type podDisruptionBudget struct { - r *PolicyClient - ns string -} - -// newPodDisruptionBudget returns a podDisruptionBudget -func newPodDisruptionBudget(c *PolicyClient, namespace string) *podDisruptionBudget { - return &podDisruptionBudget{c, namespace} -} - -// List returns a list of podDisruptionBudget that match the label and field selectors. -func (c *podDisruptionBudget) List(opts api.ListOptions) (result *policy.PodDisruptionBudgetList, err error) { - result = &policy.PodDisruptionBudgetList{} - err = c.r.Get().Namespace(c.ns).Resource("poddisruptionbudgets").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get returns information about a particular podDisruptionBudget. -func (c *podDisruptionBudget) Get(name string) (result *policy.PodDisruptionBudget, err error) { - result = &policy.PodDisruptionBudget{} - err = c.r.Get().Namespace(c.ns).Resource("poddisruptionbudgets").Name(name).Do().Into(result) - return -} - -// Create creates a new podDisruptionBudget. -func (c *podDisruptionBudget) Create(podDisruptionBudget *policy.PodDisruptionBudget) (result *policy.PodDisruptionBudget, err error) { - result = &policy.PodDisruptionBudget{} - err = c.r.Post().Namespace(c.ns).Resource("poddisruptionbudgets").Body(podDisruptionBudget).Do().Into(result) - return -} - -// Update updates an existing podDisruptionBudget. -func (c *podDisruptionBudget) Update(podDisruptionBudget *policy.PodDisruptionBudget) (result *policy.PodDisruptionBudget, err error) { - result = &policy.PodDisruptionBudget{} - err = c.r.Put().Namespace(c.ns).Resource("poddisruptionbudgets").Name(podDisruptionBudget.Name).Body(podDisruptionBudget).Do().Into(result) - return -} - -// Delete deletes a podDisruptionBudget, returns error if one occurs. -func (c *podDisruptionBudget) Delete(name string, options *api.DeleteOptions) (err error) { - return c.r.Delete().Namespace(c.ns).Resource("poddisruptionbudgets").Name(name).Body(options).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested podDisruptionBudget. -func (c *podDisruptionBudget) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("poddisruptionbudgets"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -// UpdateStatus takes the name of the podDisruptionBudget and the new status. Returns the server's representation of the podDisruptionBudget, and an error, if it occurs. -func (c *podDisruptionBudget) UpdateStatus(podDisruptionBudget *policy.PodDisruptionBudget) (result *policy.PodDisruptionBudget, err error) { - result = &policy.PodDisruptionBudget{} - err = c.r.Put().Namespace(c.ns).Resource("poddisruptionbudgets").Name(podDisruptionBudget.Name).SubResource("status").Body(podDisruptionBudget).Do().Into(result) - return -} diff --git a/pkg/client/unversioned/pod_templates.go b/pkg/client/unversioned/pod_templates.go deleted file mode 100644 index 7627d735f55cd..0000000000000 --- a/pkg/client/unversioned/pod_templates.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// PodTemplatesNamespacer has methods to work with PodTemplate resources in a namespace -type PodTemplatesNamespacer interface { - PodTemplates(namespace string) PodTemplateInterface -} - -// PodTemplateInterface has methods to work with PodTemplate resources. -type PodTemplateInterface interface { - List(opts api.ListOptions) (*api.PodTemplateList, error) - Get(name string) (*api.PodTemplate, error) - Delete(name string, options *api.DeleteOptions) error - Create(podTemplate *api.PodTemplate) (*api.PodTemplate, error) - Update(podTemplate *api.PodTemplate) (*api.PodTemplate, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// podTemplates implements PodTemplatesNamespacer interface -type podTemplates struct { - r *Client - ns string -} - -// newPodTemplates returns a podTemplates -func newPodTemplates(c *Client, namespace string) *podTemplates { - return &podTemplates{ - r: c, - ns: namespace, - } -} - -// List takes label and field selectors, and returns the list of podTemplates that match those selectors. -func (c *podTemplates) List(opts api.ListOptions) (result *api.PodTemplateList, err error) { - result = &api.PodTemplateList{} - err = c.r.Get().Namespace(c.ns).Resource("podTemplates").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get takes the name of the podTemplate, and returns the corresponding PodTemplate object, and an error if it occurs -func (c *podTemplates) Get(name string) (result *api.PodTemplate, err error) { - result = &api.PodTemplate{} - err = c.r.Get().Namespace(c.ns).Resource("podTemplates").Name(name).Do().Into(result) - return -} - -// Delete takes the name of the podTemplate, and returns an error if one occurs -func (c *podTemplates) Delete(name string, options *api.DeleteOptions) error { - return c.r.Delete().Namespace(c.ns).Resource("podTemplates").Name(name).Body(options).Do().Error() -} - -// Create takes the representation of a podTemplate. Returns the server's representation of the podTemplate, and an error, if it occurs. -func (c *podTemplates) Create(podTemplate *api.PodTemplate) (result *api.PodTemplate, err error) { - result = &api.PodTemplate{} - err = c.r.Post().Namespace(c.ns).Resource("podTemplates").Body(podTemplate).Do().Into(result) - return -} - -// Update takes the representation of a podTemplate to update. Returns the server's representation of the podTemplate, and an error, if it occurs. -func (c *podTemplates) Update(podTemplate *api.PodTemplate) (result *api.PodTemplate, err error) { - result = &api.PodTemplate{} - err = c.r.Put().Namespace(c.ns).Resource("podTemplates").Name(podTemplate.Name).Body(podTemplate).Do().Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested podTemplates. -func (c *podTemplates) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("podTemplates"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/pod_templates_test.go b/pkg/client/unversioned/pod_templates_test.go deleted file mode 100644 index d296be1aa23f2..0000000000000 --- a/pkg/client/unversioned/pod_templates_test.go +++ /dev/null @@ -1,147 +0,0 @@ -/* -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 unversioned_test - -import ( - "net/url" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getPodTemplatesResoureName() string { - return "podtemplates" -} - -func TestPodTemplateCreate(t *testing.T) { - ns := api.NamespaceDefault - podTemplate := api.PodTemplate{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: ns, - }, - Template: api.PodTemplateSpec{}, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Default.ResourcePath(getPodTemplatesResoureName(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: &podTemplate, - }, - Response: simple.Response{StatusCode: 200, Body: &podTemplate}, - } - - response, err := c.Setup(t).PodTemplates(ns).Create(&podTemplate) - defer c.Close() - c.Validate(t, response, err) -} - -func TestPodTemplateGet(t *testing.T) { - ns := api.NamespaceDefault - podTemplate := &api.PodTemplate{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: ns, - }, - Template: api.PodTemplateSpec{}, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getPodTemplatesResoureName(), ns, "abc"), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: podTemplate}, - } - - response, err := c.Setup(t).PodTemplates(ns).Get("abc") - defer c.Close() - c.Validate(t, response, err) -} - -func TestPodTemplateList(t *testing.T) { - ns := api.NamespaceDefault - podTemplateList := &api.PodTemplateList{ - Items: []api.PodTemplate{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - }, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getPodTemplatesResoureName(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: podTemplateList}, - } - response, err := c.Setup(t).PodTemplates(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, response, err) -} - -func TestPodTemplateUpdate(t *testing.T) { - ns := api.NamespaceDefault - podTemplate := &api.PodTemplate{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: ns, - ResourceVersion: "1", - }, - Template: api.PodTemplateSpec{}, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Default.ResourcePath(getPodTemplatesResoureName(), ns, "abc"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: podTemplate}, - } - response, err := c.Setup(t).PodTemplates(ns).Update(podTemplate) - defer c.Close() - c.Validate(t, response, err) -} - -func TestPodTemplateDelete(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Default.ResourcePath(getPodTemplatesResoureName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).PodTemplates(ns).Delete("foo", nil) - defer c.Close() - c.Validate(t, nil, err) -} - -func TestPodTemplateWatch(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePathWithPrefix("watch", getPodTemplatesResoureName(), "", ""), - Query: url.Values{"resourceVersion": []string{}}}, - Response: simple.Response{StatusCode: 200}, - } - _, err := c.Setup(t).PodTemplates(api.NamespaceAll).Watch(api.ListOptions{}) - defer c.Close() - c.Validate(t, nil, err) -} diff --git a/pkg/client/unversioned/pods.go b/pkg/client/unversioned/pods.go deleted file mode 100644 index ea16fb87d6942..0000000000000 --- a/pkg/client/unversioned/pods.go +++ /dev/null @@ -1,115 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/client/restclient" - "k8s.io/kubernetes/pkg/watch" -) - -// PodsNamespacer has methods to work with Pod resources in a namespace -type PodsNamespacer interface { - Pods(namespace string) PodInterface -} - -// PodInterface has methods to work with Pod resources. -type PodInterface interface { - List(opts api.ListOptions) (*api.PodList, error) - Get(name string) (*api.Pod, error) - Delete(name string, options *api.DeleteOptions) error - Create(pod *api.Pod) (*api.Pod, error) - Update(pod *api.Pod) (*api.Pod, error) - Watch(opts api.ListOptions) (watch.Interface, error) - Bind(binding *api.Binding) error - UpdateStatus(pod *api.Pod) (*api.Pod, error) - GetLogs(name string, opts *api.PodLogOptions) *restclient.Request -} - -// pods implements PodsNamespacer interface -type pods struct { - r *Client - ns string -} - -// newPods returns a pods -func newPods(c *Client, namespace string) *pods { - return &pods{ - r: c, - ns: namespace, - } -} - -// List takes label and field selectors, and returns the list of pods that match those selectors. -func (c *pods) List(opts api.ListOptions) (result *api.PodList, err error) { - result = &api.PodList{} - err = c.r.Get().Namespace(c.ns).Resource("pods").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get takes the name of the pod, and returns the corresponding Pod object, and an error if it occurs -func (c *pods) Get(name string) (result *api.Pod, err error) { - result = &api.Pod{} - err = c.r.Get().Namespace(c.ns).Resource("pods").Name(name).Do().Into(result) - return -} - -// Delete takes the name of the pod, and returns an error if one occurs -func (c *pods) Delete(name string, options *api.DeleteOptions) error { - return c.r.Delete().Namespace(c.ns).Resource("pods").Name(name).Body(options).Do().Error() -} - -// Create takes the representation of a pod. Returns the server's representation of the pod, and an error, if it occurs. -func (c *pods) Create(pod *api.Pod) (result *api.Pod, err error) { - result = &api.Pod{} - err = c.r.Post().Namespace(c.ns).Resource("pods").Body(pod).Do().Into(result) - return -} - -// Update takes the representation of a pod to update. Returns the server's representation of the pod, and an error, if it occurs. -func (c *pods) Update(pod *api.Pod) (result *api.Pod, err error) { - result = &api.Pod{} - err = c.r.Put().Namespace(c.ns).Resource("pods").Name(pod.Name).Body(pod).Do().Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested pods. -func (c *pods) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("pods"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored). -func (c *pods) Bind(binding *api.Binding) error { - return c.r.Post().Namespace(c.ns).Resource("pods").Name(binding.Name).SubResource("binding").Body(binding).Do().Error() -} - -// UpdateStatus takes the name of the pod and the new status. Returns the server's representation of the pod, and an error, if it occurs. -func (c *pods) UpdateStatus(pod *api.Pod) (result *api.Pod, err error) { - result = &api.Pod{} - err = c.r.Put().Namespace(c.ns).Resource("pods").Name(pod.Name).SubResource("status").Body(pod).Do().Into(result) - return -} - -// Get constructs a request for getting the logs for a pod -func (c *pods) GetLogs(name string, opts *api.PodLogOptions) *restclient.Request { - return c.r.Get().Namespace(c.ns).Name(name).Resource("pods").SubResource("log").VersionedParams(opts, api.ParameterCodec) -} diff --git a/pkg/client/unversioned/pods_test.go b/pkg/client/unversioned/pods_test.go deleted file mode 100644 index f405f8ed45fdb..0000000000000 --- a/pkg/client/unversioned/pods_test.go +++ /dev/null @@ -1,227 +0,0 @@ -/* -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 unversioned_test - -import ( - "net/http" - "net/url" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/apimachinery/registered" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" - "k8s.io/kubernetes/pkg/labels" -) - -func TestListEmptyPods(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "GET", Path: testapi.Default.ResourcePath("pods", ns, ""), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: http.StatusOK, Body: &api.PodList{}}, - } - podList, err := c.Setup(t).Pods(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, podList, err) -} - -func TestListPods(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "GET", Path: testapi.Default.ResourcePath("pods", ns, ""), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: http.StatusOK, - Body: &api.PodList{ - Items: []api.Pod{ - { - Status: api.PodStatus{ - Phase: api.PodRunning, - }, - ObjectMeta: api.ObjectMeta{ - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - }, - }, - }, - }, - } - receivedPodList, err := c.Setup(t).Pods(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, receivedPodList, err) -} - -func TestListPodsLabels(t *testing.T) { - ns := api.NamespaceDefault - labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(registered.GroupOrDie(api.GroupName).GroupVersion.String()) - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath("pods", ns, ""), - Query: simple.BuildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})}, - Response: simple.Response{ - StatusCode: http.StatusOK, - Body: &api.PodList{ - Items: []api.Pod{ - { - Status: api.PodStatus{ - Phase: api.PodRunning, - }, - ObjectMeta: api.ObjectMeta{ - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - }, - }, - }, - }, - } - c.Setup(t) - defer c.Close() - c.QueryValidator[labelSelectorQueryParamName] = simple.ValidateLabels - selector := labels.Set{"foo": "bar", "name": "baz"}.AsSelector() - options := api.ListOptions{LabelSelector: selector} - receivedPodList, err := c.Pods(ns).List(options) - c.Validate(t, receivedPodList, err) -} - -func TestGetPod(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "GET", Path: testapi.Default.ResourcePath("pods", ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: http.StatusOK, - Body: &api.Pod{ - Status: api.PodStatus{ - Phase: api.PodRunning, - }, - ObjectMeta: api.ObjectMeta{ - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - }, - }, - } - receivedPod, err := c.Setup(t).Pods(ns).Get("foo") - defer c.Close() - c.Validate(t, receivedPod, err) -} - -func TestGetPodWithNoName(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{Error: true} - receivedPod, err := c.Setup(t).Pods(ns).Get("") - defer c.Close() - if (err != nil) && (err.Error() != simple.NameRequiredError) { - t.Errorf("Expected error: %v, but got %v", simple.NameRequiredError, err) - } - - c.Validate(t, receivedPod, err) -} - -func TestDeletePod(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Default.ResourcePath("pods", ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: http.StatusOK}, - } - err := c.Setup(t).Pods(ns).Delete("foo", nil) - defer c.Close() - c.Validate(t, nil, err) -} - -func TestCreatePod(t *testing.T) { - ns := api.NamespaceDefault - requestPod := &api.Pod{ - Status: api.PodStatus{ - Phase: api.PodRunning, - }, - ObjectMeta: api.ObjectMeta{ - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - } - c := &simple.Client{ - Request: simple.Request{Method: "POST", Path: testapi.Default.ResourcePath("pods", ns, ""), Query: simple.BuildQueryValues(nil), Body: requestPod}, - Response: simple.Response{ - StatusCode: http.StatusOK, - Body: requestPod, - }, - } - receivedPod, err := c.Setup(t).Pods(ns).Create(requestPod) - defer c.Close() - c.Validate(t, receivedPod, err) -} - -func TestUpdatePod(t *testing.T) { - ns := api.NamespaceDefault - requestPod := &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - ResourceVersion: "1", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Status: api.PodStatus{ - Phase: api.PodRunning, - }, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Default.ResourcePath("pods", ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: http.StatusOK, Body: requestPod}, - } - receivedPod, err := c.Setup(t).Pods(ns).Update(requestPod) - defer c.Close() - c.Validate(t, receivedPod, err) -} - -func TestPodGetLogs(t *testing.T) { - ns := api.NamespaceDefault - opts := &api.PodLogOptions{ - Follow: true, - Timestamps: true, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath("pods", ns, "podName") + "/log", - Query: url.Values{ - "follow": []string{"true"}, - "timestamps": []string{"true"}, - }, - }, - Response: simple.Response{StatusCode: http.StatusOK}, - } - - body, err := c.Setup(t).Pods(ns).GetLogs("podName", opts).Stream() - defer c.Close() - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - defer body.Close() - c.ValidateCommon(t, err) -} diff --git a/pkg/client/unversioned/podsecuritypolicy.go b/pkg/client/unversioned/podsecuritypolicy.go deleted file mode 100644 index f03e643f26dd1..0000000000000 --- a/pkg/client/unversioned/podsecuritypolicy.go +++ /dev/null @@ -1,111 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/watch" -) - -type PodSecurityPoliciesInterface interface { - PodSecurityPolicies() PodSecurityPolicyInterface -} - -type PodSecurityPolicyInterface interface { - Get(name string) (result *extensions.PodSecurityPolicy, err error) - Create(psp *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error) - List(opts api.ListOptions) (*extensions.PodSecurityPolicyList, error) - Delete(name string) error - Update(*extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// podSecurityPolicy implements PodSecurityPolicyInterface -type podSecurityPolicy struct { - client *ExtensionsClient -} - -// newPodSecurityPolicy returns a podSecurityPolicy object. -func newPodSecurityPolicy(c *ExtensionsClient) *podSecurityPolicy { - return &podSecurityPolicy{c} -} - -func (s *podSecurityPolicy) Create(psp *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error) { - result := &extensions.PodSecurityPolicy{} - err := s.client.Post(). - Resource("podsecuritypolicies"). - Body(psp). - Do(). - Into(result) - - return result, err -} - -// List returns a list of PodSecurityPolicies matching the selectors. -func (s *podSecurityPolicy) List(opts api.ListOptions) (*extensions.PodSecurityPolicyList, error) { - result := &extensions.PodSecurityPolicyList{} - - err := s.client.Get(). - Resource("podsecuritypolicies"). - VersionedParams(&opts, api.ParameterCodec). - Do(). - Into(result) - - return result, err -} - -// Get returns the given PodSecurityPolicy, or an error. -func (s *podSecurityPolicy) Get(name string) (*extensions.PodSecurityPolicy, error) { - result := &extensions.PodSecurityPolicy{} - err := s.client.Get(). - Resource("podsecuritypolicies"). - Name(name). - Do(). - Into(result) - - return result, err -} - -// Watch starts watching for PodSecurityPolicies matching the given selectors. -func (s *podSecurityPolicy) Watch(opts api.ListOptions) (watch.Interface, error) { - return s.client.Get(). - Prefix("watch"). - Resource("podsecuritypolicies"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -func (s *podSecurityPolicy) Delete(name string) error { - return s.client.Delete(). - Resource("podsecuritypolicies"). - Name(name). - Do(). - Error() -} - -func (s *podSecurityPolicy) Update(psp *extensions.PodSecurityPolicy) (result *extensions.PodSecurityPolicy, err error) { - result = &extensions.PodSecurityPolicy{} - err = s.client.Put(). - Resource("podsecuritypolicies"). - Name(psp.Name). - Body(psp). - Do(). - Into(result) - - return -} diff --git a/pkg/client/unversioned/podsecuritypolicy_test.go b/pkg/client/unversioned/podsecuritypolicy_test.go deleted file mode 100644 index 0b0185f5f953e..0000000000000 --- a/pkg/client/unversioned/podsecuritypolicy_test.go +++ /dev/null @@ -1,137 +0,0 @@ -/* -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 unversioned_test - -import ( - "fmt" - "net/url" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func TestPodSecurityPolicyCreate(t *testing.T) { - ns := api.NamespaceNone - psp := &extensions.PodSecurityPolicy{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - }, - } - - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Extensions.ResourcePath(getPSPResourcename(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: psp, - }, - Response: simple.Response{StatusCode: 200, Body: psp}, - } - - response, err := c.Setup(t).PodSecurityPolicies().Create(psp) - c.Validate(t, response, err) -} - -func TestPodSecurityPolicyGet(t *testing.T) { - ns := api.NamespaceNone - psp := &extensions.PodSecurityPolicy{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Extensions.ResourcePath(getPSPResourcename(), ns, "abc"), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: psp}, - } - - response, err := c.Setup(t).PodSecurityPolicies().Get("abc") - c.Validate(t, response, err) -} - -func TestPodSecurityPolicyList(t *testing.T) { - ns := api.NamespaceNone - pspList := &extensions.PodSecurityPolicyList{ - Items: []extensions.PodSecurityPolicy{ - { - ObjectMeta: api.ObjectMeta{ - Name: "abc", - }, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Extensions.ResourcePath(getPSPResourcename(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: pspList}, - } - response, err := c.Setup(t).PodSecurityPolicies().List(api.ListOptions{}) - c.Validate(t, response, err) -} - -func TestPodSecurityPolicyUpdate(t *testing.T) { - ns := api.NamespaceNone - psp := &extensions.PodSecurityPolicy{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - ResourceVersion: "1", - }, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Extensions.ResourcePath(getPSPResourcename(), ns, "abc"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: psp}, - } - response, err := c.Setup(t).PodSecurityPolicies().Update(psp) - c.Validate(t, response, err) -} - -func TestPodSecurityPolicyDelete(t *testing.T) { - ns := api.NamespaceNone - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Extensions.ResourcePath(getPSPResourcename(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).PodSecurityPolicies().Delete("foo") - c.Validate(t, nil, err) -} - -func TestPodSecurityPolicyWatch(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: fmt.Sprintf("%s/watch/%s", testapi.Extensions.ResourcePath("", "", ""), getPSPResourcename()), - Query: url.Values{"resourceVersion": []string{}}}, - Response: simple.Response{StatusCode: 200}, - } - _, err := c.Setup(t).PodSecurityPolicies().Watch(api.ListOptions{}) - c.Validate(t, nil, err) -} - -func getPSPResourcename() string { - return "podsecuritypolicies" -} diff --git a/pkg/client/unversioned/policy.go b/pkg/client/unversioned/policy.go deleted file mode 100644 index e602795ba5ef8..0000000000000 --- a/pkg/client/unversioned/policy.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/apis/policy" - "k8s.io/kubernetes/pkg/client/restclient" -) - -type PolicyInterface interface { - PodDisruptionBudgetNamespacer -} - -// PolicyClient is used to interact with Kubernetes batch features. -type PolicyClient struct { - *restclient.RESTClient -} - -func (c *PolicyClient) PodDisruptionBudgets(namespace string) PodDisruptionBudgetInterface { - return newPodDisruptionBudget(c, namespace) -} - -func NewPolicy(c *restclient.Config) (*PolicyClient, error) { - config := *c - if err := setGroupDefaults(policy.GroupName, &config); err != nil { - return nil, err - } - client, err := restclient.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &PolicyClient{client}, nil -} - -func NewPolicyOrDie(c *restclient.Config) *PolicyClient { - client, err := NewPolicy(c) - if err != nil { - panic(err) - } - return client -} diff --git a/pkg/client/unversioned/rbac.go b/pkg/client/unversioned/rbac.go deleted file mode 100644 index c95887da12fa7..0000000000000 --- a/pkg/client/unversioned/rbac.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/apis/rbac" - "k8s.io/kubernetes/pkg/client/restclient" -) - -// Interface holds the methods for clients of Kubernetes to allow mock testing. -type RbacInterface interface { - RoleBindingsNamespacer - RolesNamespacer - ClusterRoleBindings - ClusterRoles -} - -type RbacClient struct { - *restclient.RESTClient -} - -func (c *RbacClient) RoleBindings(namespace string) RoleBindingInterface { - return newRoleBindings(c, namespace) -} - -func (c *RbacClient) Roles(namespace string) RoleInterface { - return newRoles(c, namespace) -} - -func (c *RbacClient) ClusterRoleBindings() ClusterRoleBindingInterface { - return newClusterRoleBindings(c) -} - -func (c *RbacClient) ClusterRoles() ClusterRoleInterface { - return newClusterRoles(c) -} - -// NewRbac creates a new RbacClient for the given config. -func NewRbac(c *restclient.Config) (*RbacClient, error) { - config := *c - if err := setGroupDefaults(rbac.GroupName, &config); err != nil { - return nil, err - } - client, err := restclient.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &RbacClient{client}, nil -} - -// NewRbacOrDie creates a new RbacClient for the given config and -// panics if there is an error in the config. -func NewRbacOrDie(c *restclient.Config) *RbacClient { - client, err := NewRbac(c) - if err != nil { - panic(err) - } - return client -} diff --git a/pkg/client/unversioned/replica_sets.go b/pkg/client/unversioned/replica_sets.go deleted file mode 100644 index 191a006b60436..0000000000000 --- a/pkg/client/unversioned/replica_sets.go +++ /dev/null @@ -1,100 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/watch" -) - -// ReplicaSetsNamespacer has methods to work with ReplicaSet resources in a namespace -type ReplicaSetsNamespacer interface { - ReplicaSets(namespace string) ReplicaSetInterface -} - -// ReplicaSetInterface has methods to work with ReplicaSet resources. -type ReplicaSetInterface interface { - List(opts api.ListOptions) (*extensions.ReplicaSetList, error) - Get(name string) (*extensions.ReplicaSet, error) - Create(ctrl *extensions.ReplicaSet) (*extensions.ReplicaSet, error) - Update(ctrl *extensions.ReplicaSet) (*extensions.ReplicaSet, error) - UpdateStatus(ctrl *extensions.ReplicaSet) (*extensions.ReplicaSet, error) - Delete(name string, options *api.DeleteOptions) error - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// replicaSets implements ReplicaSetsNamespacer interface -type replicaSets struct { - client *ExtensionsClient - ns string -} - -// newReplicaSets returns a ReplicaSetClient -func newReplicaSets(c *ExtensionsClient, namespace string) *replicaSets { - return &replicaSets{c, namespace} -} - -// List takes a selector, and returns the list of ReplicaSets that match that selector. -func (c *replicaSets) List(opts api.ListOptions) (result *extensions.ReplicaSetList, err error) { - result = &extensions.ReplicaSetList{} - err = c.client.Get().Namespace(c.ns).Resource("replicasets").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get returns information about a particular ReplicaSet. -func (c *replicaSets) Get(name string) (result *extensions.ReplicaSet, err error) { - result = &extensions.ReplicaSet{} - err = c.client.Get().Namespace(c.ns).Resource("replicasets").Name(name).Do().Into(result) - return -} - -// Create creates a new ReplicaSet. -func (c *replicaSets) Create(rs *extensions.ReplicaSet) (result *extensions.ReplicaSet, err error) { - result = &extensions.ReplicaSet{} - err = c.client.Post().Namespace(c.ns).Resource("replicasets").Body(rs).Do().Into(result) - return -} - -// Update updates an existing ReplicaSet. -func (c *replicaSets) Update(rs *extensions.ReplicaSet) (result *extensions.ReplicaSet, err error) { - result = &extensions.ReplicaSet{} - err = c.client.Put().Namespace(c.ns).Resource("replicasets").Name(rs.Name).Body(rs).Do().Into(result) - return -} - -// UpdateStatus updates an existing ReplicaSet status -func (c *replicaSets) UpdateStatus(rs *extensions.ReplicaSet) (result *extensions.ReplicaSet, err error) { - result = &extensions.ReplicaSet{} - err = c.client.Put().Namespace(c.ns).Resource("replicasets").Name(rs.Name).SubResource("status").Body(rs).Do().Into(result) - return -} - -// Delete deletes an existing ReplicaSet. -func (c *replicaSets) Delete(name string, options *api.DeleteOptions) (err error) { - return c.client.Delete().Namespace(c.ns).Resource("replicasets").Name(name).Body(options).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested ReplicaSets. -func (c *replicaSets) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.client.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("replicasets"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/replica_sets_test.go b/pkg/client/unversioned/replica_sets_test.go deleted file mode 100644 index e662610e27886..0000000000000 --- a/pkg/client/unversioned/replica_sets_test.go +++ /dev/null @@ -1,193 +0,0 @@ -/* -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 unversioned_test - -import ( - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getReplicaSetResourceName() string { - return "replicasets" -} - -func TestListReplicaSets(t *testing.T) { - ns := api.NamespaceAll - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Extensions.ResourcePath(getReplicaSetResourceName(), ns, ""), - }, - Response: simple.Response{StatusCode: 200, - Body: &extensions.ReplicaSetList{ - Items: []extensions.ReplicaSet{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.ReplicaSetSpec{ - Replicas: 2, - Template: api.PodTemplateSpec{}, - }, - }, - }, - }, - }, - } - receivedRSList, err := c.Setup(t).Extensions().ReplicaSets(ns).List(api.ListOptions{}) - c.Validate(t, receivedRSList, err) -} - -func TestGetReplicaSet(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "GET", Path: testapi.Extensions.ResourcePath(getReplicaSetResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.ReplicaSet{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.ReplicaSetSpec{ - Replicas: 2, - Template: api.PodTemplateSpec{}, - }, - }, - }, - } - receivedRS, err := c.Setup(t).Extensions().ReplicaSets(ns).Get("foo") - c.Validate(t, receivedRS, err) -} - -func TestGetReplicaSetWithNoName(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{Error: true} - receivedPod, err := c.Setup(t).Extensions().ReplicaSets(ns).Get("") - if (err != nil) && (err.Error() != simple.NameRequiredError) { - t.Errorf("Expected error: %v, but got %v", simple.NameRequiredError, err) - } - - c.Validate(t, receivedPod, err) -} - -func TestUpdateReplicaSet(t *testing.T) { - ns := api.NamespaceDefault - requestRS := &extensions.ReplicaSet{ - ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Extensions.ResourcePath(getReplicaSetResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.ReplicaSet{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.ReplicaSetSpec{ - Replicas: 2, - Template: api.PodTemplateSpec{}, - }, - }, - }, - } - receivedRS, err := c.Setup(t).Extensions().ReplicaSets(ns).Update(requestRS) - c.Validate(t, receivedRS, err) -} - -func TestUpdateStatusReplicaSet(t *testing.T) { - ns := api.NamespaceDefault - requestRS := &extensions.ReplicaSet{ - ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Extensions.ResourcePath(getReplicaSetResourceName(), ns, "foo") + "/status", Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.ReplicaSet{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.ReplicaSetSpec{ - Replicas: 2, - Template: api.PodTemplateSpec{}, - }, - Status: extensions.ReplicaSetStatus{ - Replicas: 2, - }, - }, - }, - } - receivedRS, err := c.Setup(t).Extensions().ReplicaSets(ns).UpdateStatus(requestRS) - c.Validate(t, receivedRS, err) -} -func TestDeleteReplicaSet(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Extensions.ResourcePath(getReplicaSetResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).Extensions().ReplicaSets(ns).Delete("foo", nil) - c.Validate(t, nil, err) -} - -func TestCreateReplicaSet(t *testing.T) { - ns := api.NamespaceDefault - requestRS := &extensions.ReplicaSet{ - ObjectMeta: api.ObjectMeta{Name: "foo"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "POST", Path: testapi.Extensions.ResourcePath(getReplicaSetResourceName(), ns, ""), Body: requestRS, Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.ReplicaSet{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: extensions.ReplicaSetSpec{ - Replicas: 2, - Template: api.PodTemplateSpec{}, - }, - }, - }, - } - receivedRS, err := c.Setup(t).Extensions().ReplicaSets(ns).Create(requestRS) - c.Validate(t, receivedRS, err) -} diff --git a/pkg/client/unversioned/replication_controllers.go b/pkg/client/unversioned/replication_controllers.go deleted file mode 100644 index 5c3b2c305e051..0000000000000 --- a/pkg/client/unversioned/replication_controllers.go +++ /dev/null @@ -1,99 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// ReplicationControllersNamespacer has methods to work with ReplicationController resources in a namespace -type ReplicationControllersNamespacer interface { - ReplicationControllers(namespace string) ReplicationControllerInterface -} - -// ReplicationControllerInterface has methods to work with ReplicationController resources. -type ReplicationControllerInterface interface { - List(opts api.ListOptions) (*api.ReplicationControllerList, error) - Get(name string) (*api.ReplicationController, error) - Create(ctrl *api.ReplicationController) (*api.ReplicationController, error) - Update(ctrl *api.ReplicationController) (*api.ReplicationController, error) - UpdateStatus(ctrl *api.ReplicationController) (*api.ReplicationController, error) - Delete(name string, options *api.DeleteOptions) error - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// replicationControllers implements ReplicationControllersNamespacer interface -type replicationControllers struct { - r *Client - ns string -} - -// newReplicationControllers returns a PodsClient -func newReplicationControllers(c *Client, namespace string) *replicationControllers { - return &replicationControllers{c, namespace} -} - -// List takes a selector, and returns the list of replication controllers that match that selector. -func (c *replicationControllers) List(opts api.ListOptions) (result *api.ReplicationControllerList, err error) { - result = &api.ReplicationControllerList{} - err = c.r.Get().Namespace(c.ns).Resource("replicationControllers").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get returns information about a particular replication controller. -func (c *replicationControllers) Get(name string) (result *api.ReplicationController, err error) { - result = &api.ReplicationController{} - err = c.r.Get().Namespace(c.ns).Resource("replicationControllers").Name(name).Do().Into(result) - return -} - -// Create creates a new replication controller. -func (c *replicationControllers) Create(controller *api.ReplicationController) (result *api.ReplicationController, err error) { - result = &api.ReplicationController{} - err = c.r.Post().Namespace(c.ns).Resource("replicationControllers").Body(controller).Do().Into(result) - return -} - -// Update updates an existing replication controller. -func (c *replicationControllers) Update(controller *api.ReplicationController) (result *api.ReplicationController, err error) { - result = &api.ReplicationController{} - err = c.r.Put().Namespace(c.ns).Resource("replicationControllers").Name(controller.Name).Body(controller).Do().Into(result) - return -} - -// UpdateStatus updates an existing replication controller status -func (c *replicationControllers) UpdateStatus(controller *api.ReplicationController) (result *api.ReplicationController, err error) { - result = &api.ReplicationController{} - err = c.r.Put().Namespace(c.ns).Resource("replicationControllers").Name(controller.Name).SubResource("status").Body(controller).Do().Into(result) - return -} - -// Delete deletes an existing replication controller. -func (c *replicationControllers) Delete(name string, options *api.DeleteOptions) error { - return c.r.Delete().Namespace(c.ns).Resource("replicationControllers").Name(name).Body(options).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested controllers. -func (c *replicationControllers) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("replicationControllers"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/replication_controllers_test.go b/pkg/client/unversioned/replication_controllers_test.go deleted file mode 100644 index f54d3d7913bd7..0000000000000 --- a/pkg/client/unversioned/replication_controllers_test.go +++ /dev/null @@ -1,200 +0,0 @@ -/* -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 unversioned_test - -import ( - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getRCResourceName() string { - return "replicationcontrollers" -} - -func TestListControllers(t *testing.T) { - ns := api.NamespaceAll - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getRCResourceName(), ns, ""), - }, - Response: simple.Response{StatusCode: 200, - Body: &api.ReplicationControllerList{ - Items: []api.ReplicationController{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: api.ReplicationControllerSpec{ - Replicas: 2, - Template: &api.PodTemplateSpec{}, - }, - }, - }, - }, - }, - } - receivedControllerList, err := c.Setup(t).ReplicationControllers(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, receivedControllerList, err) - -} - -func TestGetController(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "GET", Path: testapi.Default.ResourcePath(getRCResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &api.ReplicationController{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: api.ReplicationControllerSpec{ - Replicas: 2, - Template: &api.PodTemplateSpec{}, - }, - }, - }, - } - receivedController, err := c.Setup(t).ReplicationControllers(ns).Get("foo") - defer c.Close() - c.Validate(t, receivedController, err) -} - -func TestGetControllerWithNoName(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{Error: true} - receivedPod, err := c.Setup(t).ReplicationControllers(ns).Get("") - defer c.Close() - if (err != nil) && (err.Error() != simple.NameRequiredError) { - t.Errorf("Expected error: %v, but got %v", simple.NameRequiredError, err) - } - - c.Validate(t, receivedPod, err) -} - -func TestUpdateController(t *testing.T) { - ns := api.NamespaceDefault - requestController := &api.ReplicationController{ - ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Default.ResourcePath(getRCResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &api.ReplicationController{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: api.ReplicationControllerSpec{ - Replicas: 2, - Template: &api.PodTemplateSpec{}, - }, - }, - }, - } - receivedController, err := c.Setup(t).ReplicationControllers(ns).Update(requestController) - defer c.Close() - c.Validate(t, receivedController, err) -} - -func TestUpdateStatusController(t *testing.T) { - ns := api.NamespaceDefault - requestController := &api.ReplicationController{ - ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Default.ResourcePath(getRCResourceName(), ns, "foo") + "/status", Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &api.ReplicationController{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: api.ReplicationControllerSpec{ - Replicas: 2, - Template: &api.PodTemplateSpec{}, - }, - Status: api.ReplicationControllerStatus{ - Replicas: 2, - }, - }, - }, - } - receivedController, err := c.Setup(t).ReplicationControllers(ns).UpdateStatus(requestController) - defer c.Close() - c.Validate(t, receivedController, err) -} -func TestDeleteController(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Default.ResourcePath(getRCResourceName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).ReplicationControllers(ns).Delete("foo", nil) - defer c.Close() - c.Validate(t, nil, err) -} - -func TestCreateController(t *testing.T) { - ns := api.NamespaceDefault - requestController := &api.ReplicationController{ - ObjectMeta: api.ObjectMeta{Name: "foo"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "POST", Path: testapi.Default.ResourcePath(getRCResourceName(), ns, ""), Body: requestController, Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &api.ReplicationController{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: api.ReplicationControllerSpec{ - Replicas: 2, - Template: &api.PodTemplateSpec{}, - }, - }, - }, - } - receivedController, err := c.Setup(t).ReplicationControllers(ns).Create(requestController) - defer c.Close() - c.Validate(t, receivedController, err) -} diff --git a/pkg/client/unversioned/resource_quotas.go b/pkg/client/unversioned/resource_quotas.go deleted file mode 100644 index 9944cef9bb8ee..0000000000000 --- a/pkg/client/unversioned/resource_quotas.go +++ /dev/null @@ -1,102 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// ResourceQuotasNamespacer has methods to work with ResourceQuota resources in a namespace -type ResourceQuotasNamespacer interface { - ResourceQuotas(namespace string) ResourceQuotaInterface -} - -// ResourceQuotaInterface has methods to work with ResourceQuota resources. -type ResourceQuotaInterface interface { - List(opts api.ListOptions) (*api.ResourceQuotaList, error) - Get(name string) (*api.ResourceQuota, error) - Delete(name string) error - Create(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error) - Update(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error) - UpdateStatus(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// resourceQuotas implements ResourceQuotasNamespacer interface -type resourceQuotas struct { - r *Client - ns string -} - -// newResourceQuotas returns a resourceQuotas -func newResourceQuotas(c *Client, namespace string) *resourceQuotas { - return &resourceQuotas{ - r: c, - ns: namespace, - } -} - -// List takes a selector, and returns the list of resourceQuotas that match that selector. -func (c *resourceQuotas) List(opts api.ListOptions) (result *api.ResourceQuotaList, err error) { - result = &api.ResourceQuotaList{} - err = c.r.Get().Namespace(c.ns).Resource("resourceQuotas").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get takes the name of the resourceQuota, and returns the corresponding ResourceQuota object, and an error if it occurs -func (c *resourceQuotas) Get(name string) (result *api.ResourceQuota, err error) { - result = &api.ResourceQuota{} - err = c.r.Get().Namespace(c.ns).Resource("resourceQuotas").Name(name).Do().Into(result) - return -} - -// Delete takes the name of the resourceQuota, and returns an error if one occurs -func (c *resourceQuotas) Delete(name string) error { - return c.r.Delete().Namespace(c.ns).Resource("resourceQuotas").Name(name).Do().Error() -} - -// Create takes the representation of a resourceQuota. Returns the server's representation of the resourceQuota, and an error, if it occurs. -func (c *resourceQuotas) Create(resourceQuota *api.ResourceQuota) (result *api.ResourceQuota, err error) { - result = &api.ResourceQuota{} - err = c.r.Post().Namespace(c.ns).Resource("resourceQuotas").Body(resourceQuota).Do().Into(result) - return -} - -// Update takes the representation of a resourceQuota to update spec. Returns the server's representation of the resourceQuota, and an error, if it occurs. -func (c *resourceQuotas) Update(resourceQuota *api.ResourceQuota) (result *api.ResourceQuota, err error) { - result = &api.ResourceQuota{} - err = c.r.Put().Namespace(c.ns).Resource("resourceQuotas").Name(resourceQuota.Name).Body(resourceQuota).Do().Into(result) - return -} - -// Status takes the representation of a resourceQuota to update status. Returns the server's representation of the resourceQuota, and an error, if it occurs. -func (c *resourceQuotas) UpdateStatus(resourceQuota *api.ResourceQuota) (result *api.ResourceQuota, err error) { - result = &api.ResourceQuota{} - err = c.r.Put().Namespace(c.ns).Resource("resourceQuotas").Name(resourceQuota.Name).SubResource("status").Body(resourceQuota).Do().Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested resource -func (c *resourceQuotas) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("resourceQuotas"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/resource_quotas_test.go b/pkg/client/unversioned/resource_quotas_test.go deleted file mode 100644 index 32317bcc4b919..0000000000000 --- a/pkg/client/unversioned/resource_quotas_test.go +++ /dev/null @@ -1,204 +0,0 @@ -/* -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 unversioned_test - -import ( - "net/url" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/resource" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getResourceQuotasResoureName() string { - return "resourcequotas" -} - -func TestResourceQuotaCreate(t *testing.T) { - ns := api.NamespaceDefault - resourceQuota := &api.ResourceQuota{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: "foo", - }, - Spec: api.ResourceQuotaSpec{ - Hard: api.ResourceList{ - api.ResourceCPU: resource.MustParse("100"), - api.ResourceMemory: resource.MustParse("10000"), - api.ResourcePods: resource.MustParse("10"), - api.ResourceServices: resource.MustParse("10"), - api.ResourceReplicationControllers: resource.MustParse("10"), - api.ResourceQuotas: resource.MustParse("10"), - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Default.ResourcePath(getResourceQuotasResoureName(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: resourceQuota, - }, - Response: simple.Response{StatusCode: 200, Body: resourceQuota}, - } - - response, err := c.Setup(t).ResourceQuotas(ns).Create(resourceQuota) - defer c.Close() - c.Validate(t, response, err) -} - -func TestResourceQuotaGet(t *testing.T) { - ns := api.NamespaceDefault - resourceQuota := &api.ResourceQuota{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: "foo", - }, - Spec: api.ResourceQuotaSpec{ - Hard: api.ResourceList{ - api.ResourceCPU: resource.MustParse("100"), - api.ResourceMemory: resource.MustParse("10000"), - api.ResourcePods: resource.MustParse("10"), - api.ResourceServices: resource.MustParse("10"), - api.ResourceReplicationControllers: resource.MustParse("10"), - api.ResourceQuotas: resource.MustParse("10"), - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getResourceQuotasResoureName(), ns, "abc"), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: resourceQuota}, - } - - response, err := c.Setup(t).ResourceQuotas(ns).Get("abc") - defer c.Close() - c.Validate(t, response, err) -} - -func TestResourceQuotaList(t *testing.T) { - ns := api.NamespaceDefault - - resourceQuotaList := &api.ResourceQuotaList{ - Items: []api.ResourceQuota{ - { - ObjectMeta: api.ObjectMeta{Name: "foo"}, - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath(getResourceQuotasResoureName(), ns, ""), - Query: simple.BuildQueryValues(nil), - Body: nil, - }, - Response: simple.Response{StatusCode: 200, Body: resourceQuotaList}, - } - response, err := c.Setup(t).ResourceQuotas(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, response, err) -} - -func TestResourceQuotaUpdate(t *testing.T) { - ns := api.NamespaceDefault - resourceQuota := &api.ResourceQuota{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: "foo", - ResourceVersion: "1", - }, - Spec: api.ResourceQuotaSpec{ - Hard: api.ResourceList{ - api.ResourceCPU: resource.MustParse("100"), - api.ResourceMemory: resource.MustParse("10000"), - api.ResourcePods: resource.MustParse("10"), - api.ResourceServices: resource.MustParse("10"), - api.ResourceReplicationControllers: resource.MustParse("10"), - api.ResourceQuotas: resource.MustParse("10"), - }, - }, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Default.ResourcePath(getResourceQuotasResoureName(), ns, "abc"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: resourceQuota}, - } - response, err := c.Setup(t).ResourceQuotas(ns).Update(resourceQuota) - defer c.Close() - c.Validate(t, response, err) -} - -func TestResourceQuotaStatusUpdate(t *testing.T) { - ns := api.NamespaceDefault - resourceQuota := &api.ResourceQuota{ - ObjectMeta: api.ObjectMeta{ - Name: "abc", - Namespace: "foo", - ResourceVersion: "1", - }, - Status: api.ResourceQuotaStatus{ - Hard: api.ResourceList{ - api.ResourceCPU: resource.MustParse("100"), - api.ResourceMemory: resource.MustParse("10000"), - api.ResourcePods: resource.MustParse("10"), - api.ResourceServices: resource.MustParse("10"), - api.ResourceReplicationControllers: resource.MustParse("10"), - api.ResourceQuotas: resource.MustParse("10"), - }, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Default.ResourcePath(getResourceQuotasResoureName(), ns, "abc") + "/status", - Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: resourceQuota}, - } - response, err := c.Setup(t).ResourceQuotas(ns).UpdateStatus(resourceQuota) - defer c.Close() - c.Validate(t, response, err) -} - -func TestResourceQuotaDelete(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Default.ResourcePath(getResourceQuotasResoureName(), ns, "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).ResourceQuotas(ns).Delete("foo") - defer c.Close() - c.Validate(t, nil, err) -} - -func TestResourceQuotaWatch(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePathWithPrefix("watch", getResourceQuotasResoureName(), "", ""), - Query: url.Values{"resourceVersion": []string{}}}, - Response: simple.Response{StatusCode: 200}, - } - _, err := c.Setup(t).ResourceQuotas(api.NamespaceAll).Watch(api.ListOptions{}) - defer c.Close() - c.Validate(t, nil, err) -} diff --git a/pkg/client/unversioned/rolebindings.go b/pkg/client/unversioned/rolebindings.go deleted file mode 100644 index b79838010d107..0000000000000 --- a/pkg/client/unversioned/rolebindings.go +++ /dev/null @@ -1,95 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/rbac" - "k8s.io/kubernetes/pkg/watch" -) - -// RoleBindingsNamespacer has methods to work with RoleBinding resources in a namespace -type RoleBindingsNamespacer interface { - RoleBindings(namespace string) RoleBindingInterface -} - -// RoleBindingInterface has methods to work with RoleBinding resources. -type RoleBindingInterface interface { - List(opts api.ListOptions) (*rbac.RoleBindingList, error) - Get(name string) (*rbac.RoleBinding, error) - Delete(name string, options *api.DeleteOptions) error - Create(roleBinding *rbac.RoleBinding) (*rbac.RoleBinding, error) - Update(roleBinding *rbac.RoleBinding) (*rbac.RoleBinding, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// roleBindings implements RoleBindingsNamespacer interface -type roleBindings struct { - client *RbacClient - ns string -} - -// newRoleBindings returns a roleBindings -func newRoleBindings(c *RbacClient, namespace string) *roleBindings { - return &roleBindings{ - client: c, - ns: namespace, - } -} - -// List takes label and field selectors, and returns the list of roleBindings that match those selectors. -func (c *roleBindings) List(opts api.ListOptions) (result *rbac.RoleBindingList, err error) { - result = &rbac.RoleBindingList{} - err = c.client.Get().Namespace(c.ns).Resource("rolebindings").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get takes the name of the roleBinding, and returns the corresponding RoleBinding object, and an error if it occurs -func (c *roleBindings) Get(name string) (result *rbac.RoleBinding, err error) { - result = &rbac.RoleBinding{} - err = c.client.Get().Namespace(c.ns).Resource("rolebindings").Name(name).Do().Into(result) - return -} - -// Delete takes the name of the roleBinding and deletes it. Returns an error if one occurs. -func (c *roleBindings) Delete(name string, options *api.DeleteOptions) error { - return c.client.Delete().Namespace(c.ns).Resource("rolebindings").Name(name).Body(options).Do().Error() -} - -// Create takes the representation of a roleBinding and creates it. Returns the server's representation of the roleBinding, and an error, if it occurs. -func (c *roleBindings) Create(roleBinding *rbac.RoleBinding) (result *rbac.RoleBinding, err error) { - result = &rbac.RoleBinding{} - err = c.client.Post().Namespace(c.ns).Resource("rolebindings").Body(roleBinding).Do().Into(result) - return -} - -// Update takes the representation of a roleBinding and updates it. Returns the server's representation of the roleBinding, and an error, if it occurs. -func (c *roleBindings) Update(roleBinding *rbac.RoleBinding) (result *rbac.RoleBinding, err error) { - result = &rbac.RoleBinding{} - err = c.client.Put().Namespace(c.ns).Resource("rolebindings").Name(roleBinding.Name).Body(roleBinding).Do().Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested roleBindings. -func (c *roleBindings) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.client.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("rolebindings"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/roles.go b/pkg/client/unversioned/roles.go deleted file mode 100644 index b265e787b5039..0000000000000 --- a/pkg/client/unversioned/roles.go +++ /dev/null @@ -1,95 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/rbac" - "k8s.io/kubernetes/pkg/watch" -) - -// RolesNamespacer has methods to work with Role resources in a namespace -type RolesNamespacer interface { - Roles(namespace string) RoleInterface -} - -// RoleInterface has methods to work with Role resources. -type RoleInterface interface { - List(opts api.ListOptions) (*rbac.RoleList, error) - Get(name string) (*rbac.Role, error) - Delete(name string, options *api.DeleteOptions) error - Create(role *rbac.Role) (*rbac.Role, error) - Update(role *rbac.Role) (*rbac.Role, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// roles implements RolesNamespacer interface -type roles struct { - client *RbacClient - ns string -} - -// newRoles returns a roles -func newRoles(c *RbacClient, namespace string) *roles { - return &roles{ - client: c, - ns: namespace, - } -} - -// List takes label and field selectors, and returns the list of roles that match those selectors. -func (c *roles) List(opts api.ListOptions) (result *rbac.RoleList, err error) { - result = &rbac.RoleList{} - err = c.client.Get().Namespace(c.ns).Resource("roles").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get takes the name of the role, and returns the corresponding Role object, and an error if it occurs -func (c *roles) Get(name string) (result *rbac.Role, err error) { - result = &rbac.Role{} - err = c.client.Get().Namespace(c.ns).Resource("roles").Name(name).Do().Into(result) - return -} - -// Delete takes the name of the role and deletes it. Returns an error if one occurs. -func (c *roles) Delete(name string, options *api.DeleteOptions) error { - return c.client.Delete().Namespace(c.ns).Resource("roles").Name(name).Body(options).Do().Error() -} - -// Create takes the representation of a role and creates it. Returns the server's representation of the role, and an error, if it occurs. -func (c *roles) Create(role *rbac.Role) (result *rbac.Role, err error) { - result = &rbac.Role{} - err = c.client.Post().Namespace(c.ns).Resource("roles").Body(role).Do().Into(result) - return -} - -// Update takes the representation of a role and updates it. Returns the server's representation of the role, and an error, if it occurs. -func (c *roles) Update(role *rbac.Role) (result *rbac.Role, err error) { - result = &rbac.Role{} - err = c.client.Put().Namespace(c.ns).Resource("roles").Name(role.Name).Body(role).Do().Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested roles. -func (c *roles) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.client.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("roles"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/scale.go b/pkg/client/unversioned/scale.go deleted file mode 100644 index a55b0777dbc63..0000000000000 --- a/pkg/client/unversioned/scale.go +++ /dev/null @@ -1,77 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api/meta" - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/apis/extensions" -) - -type ScaleNamespacer interface { - Scales(namespace string) ScaleInterface -} - -// ScaleInterface has methods to work with Scale (sub)resources. -type ScaleInterface interface { - Get(string, string) (*extensions.Scale, error) - Update(string, *extensions.Scale) (*extensions.Scale, error) -} - -// horizontalPodAutoscalers implements HorizontalPodAutoscalersNamespacer interface -type scales struct { - client *ExtensionsClient - ns string -} - -// newHorizontalPodAutoscalers returns a horizontalPodAutoscalers -func newScales(c *ExtensionsClient, namespace string) *scales { - return &scales{ - client: c, - ns: namespace, - } -} - -// Get takes the reference to scale subresource and returns the subresource or error, if one occurs. -func (c *scales) Get(kind string, name string) (result *extensions.Scale, err error) { - result = &extensions.Scale{} - - // TODO this method needs to take a proper unambiguous kind - fullyQualifiedKind := unversioned.GroupVersionKind{Kind: kind} - resource, _ := meta.KindToResource(fullyQualifiedKind) - - err = c.client.Get().Namespace(c.ns).Resource(resource.Resource).Name(name).SubResource("scale").Do().Into(result) - return -} - -func (c *scales) Update(kind string, scale *extensions.Scale) (result *extensions.Scale, err error) { - result = &extensions.Scale{} - - // TODO this method needs to take a proper unambiguous kind - fullyQualifiedKind := unversioned.GroupVersionKind{Kind: kind} - resource, _ := meta.KindToResource(fullyQualifiedKind) - - err = c.client.Put(). - Namespace(scale.Namespace). - Resource(resource.Resource). - Name(scale.Name). - SubResource("scale"). - Body(scale). - Do(). - Into(result) - return -} diff --git a/pkg/client/unversioned/scheduledjobs.go b/pkg/client/unversioned/scheduledjobs.go deleted file mode 100644 index 5c9222cf02809..0000000000000 --- a/pkg/client/unversioned/scheduledjobs.go +++ /dev/null @@ -1,103 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/batch" - "k8s.io/kubernetes/pkg/watch" -) - -// ScheduledJobsNamespacer has methods to work with ScheduledJob resources in a namespace -type ScheduledJobsNamespacer interface { - ScheduledJobs(namespace string) ScheduledJobInterface -} - -// ScheduledJobInterface exposes methods to work on ScheduledJob resources. -type ScheduledJobInterface interface { - List(opts api.ListOptions) (*batch.ScheduledJobList, error) - Get(name string) (*batch.ScheduledJob, error) - Create(scheduledJob *batch.ScheduledJob) (*batch.ScheduledJob, error) - Update(scheduledJob *batch.ScheduledJob) (*batch.ScheduledJob, error) - Delete(name string, options *api.DeleteOptions) error - Watch(opts api.ListOptions) (watch.Interface, error) - UpdateStatus(scheduledJob *batch.ScheduledJob) (*batch.ScheduledJob, error) -} - -// scheduledJobs implements ScheduledJobsNamespacer interface -type scheduledJobs struct { - r *BatchClient - ns string -} - -// newScheduledJobs returns a scheduledJobs -func newScheduledJobs(c *BatchClient, namespace string) *scheduledJobs { - return &scheduledJobs{c, namespace} -} - -// Ensure statically that scheduledJobs implements ScheduledJobInterface. -var _ ScheduledJobInterface = &scheduledJobs{} - -// List returns a list of scheduled jobs that match the label and field selectors. -func (c *scheduledJobs) List(opts api.ListOptions) (result *batch.ScheduledJobList, err error) { - result = &batch.ScheduledJobList{} - err = c.r.Get().Namespace(c.ns).Resource("scheduledjobs").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get returns information about a particular scheduled job. -func (c *scheduledJobs) Get(name string) (result *batch.ScheduledJob, err error) { - result = &batch.ScheduledJob{} - err = c.r.Get().Namespace(c.ns).Resource("scheduledjobs").Name(name).Do().Into(result) - return -} - -// Create creates a new scheduled job. -func (c *scheduledJobs) Create(job *batch.ScheduledJob) (result *batch.ScheduledJob, err error) { - result = &batch.ScheduledJob{} - err = c.r.Post().Namespace(c.ns).Resource("scheduledjobs").Body(job).Do().Into(result) - return -} - -// Update updates an existing scheduled job. -func (c *scheduledJobs) Update(job *batch.ScheduledJob) (result *batch.ScheduledJob, err error) { - result = &batch.ScheduledJob{} - err = c.r.Put().Namespace(c.ns).Resource("scheduledjobs").Name(job.Name).Body(job).Do().Into(result) - return -} - -// Delete deletes a scheduled job, returns error if one occurs. -func (c *scheduledJobs) Delete(name string, options *api.DeleteOptions) (err error) { - return c.r.Delete().Namespace(c.ns).Resource("scheduledjobs").Name(name).Body(options).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested scheduled jobs. -func (c *scheduledJobs) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("scheduledjobs"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -// UpdateStatus takes the name of the scheduled job and the new status. Returns the server's representation of the scheduled job, and an error, if it occurs. -func (c *scheduledJobs) UpdateStatus(job *batch.ScheduledJob) (result *batch.ScheduledJob, err error) { - result = &batch.ScheduledJob{} - err = c.r.Put().Namespace(c.ns).Resource("scheduledjobs").Name(job.Name).SubResource("status").Body(job).Do().Into(result) - return -} diff --git a/pkg/client/unversioned/scheduledjobs_test.go b/pkg/client/unversioned/scheduledjobs_test.go deleted file mode 100644 index 975d1503c30b3..0000000000000 --- a/pkg/client/unversioned/scheduledjobs_test.go +++ /dev/null @@ -1,277 +0,0 @@ -/* -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 unversioned_test - -import ( - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/apis/batch" - "k8s.io/kubernetes/pkg/apis/batch/v2alpha1" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getScheduledJobsResource() string { - return "scheduledjobs" -} - -func TestListScheduledJob(t *testing.T) { - // scheduled jobs should be tested only when batch/v2alpha1 is enabled - if *testapi.Batch.GroupVersion() != v2alpha1.SchemeGroupVersion { - return - } - - ns := api.NamespaceAll - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Batch.ResourcePath(getScheduledJobsResource(), ns, ""), - }, - Response: simple.Response{StatusCode: 200, - Body: &batch.ScheduledJobList{ - Items: []batch.ScheduledJob{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: batch.ScheduledJobSpec{ - JobTemplate: batch.JobTemplateSpec{ - Spec: batch.JobSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - }, - }, - }, - }, - ResourceGroup: batch.GroupName, - } - receivedScheduledJobList, err := c.Setup(t).Batch().ScheduledJobs(ns).List(api.ListOptions{}) - defer c.Close() - c.Validate(t, receivedScheduledJobList, err) -} - -func TestGetScheduledJob(t *testing.T) { - // scheduled jobs should be tested only when batch/v2alpha1 is enabled - if *testapi.Batch.GroupVersion() != v2alpha1.SchemeGroupVersion { - return - } - - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Batch.ResourcePath(getScheduledJobsResource(), ns, "foo"), - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &batch.ScheduledJob{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: batch.ScheduledJobSpec{ - JobTemplate: batch.JobTemplateSpec{ - Spec: batch.JobSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - }, - }, - ResourceGroup: batch.GroupName, - } - receivedScheduledJob, err := c.Setup(t).Batch().ScheduledJobs(ns).Get("foo") - defer c.Close() - c.Validate(t, receivedScheduledJob, err) -} - -func TestUpdateScheduledJob(t *testing.T) { - // scheduled jobs should be tested only when batch/v2alpha1 is enabled - if *testapi.Batch.GroupVersion() != v2alpha1.SchemeGroupVersion { - return - } - - ns := api.NamespaceDefault - requestScheduledJob := &batch.ScheduledJob{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - ResourceVersion: "1", - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Batch.ResourcePath(getScheduledJobsResource(), ns, "foo"), - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &batch.ScheduledJob{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: batch.ScheduledJobSpec{ - JobTemplate: batch.JobTemplateSpec{ - Spec: batch.JobSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - }, - }, - ResourceGroup: batch.GroupName, - } - receivedScheduledJob, err := c.Setup(t).Batch().ScheduledJobs(ns).Update(requestScheduledJob) - defer c.Close() - c.Validate(t, receivedScheduledJob, err) -} - -func TestUpdateScheduledJobStatus(t *testing.T) { - // scheduled jobs should be tested only when batch/v2alpha1 is enabled - if *testapi.Batch.GroupVersion() != v2alpha1.SchemeGroupVersion { - return - } - - ns := api.NamespaceDefault - requestScheduledJob := &batch.ScheduledJob{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - ResourceVersion: "1", - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Batch.ResourcePath(getScheduledJobsResource(), ns, "foo") + "/status", - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &batch.ScheduledJob{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: batch.ScheduledJobSpec{ - ConcurrencyPolicy: batch.AllowConcurrent, - JobTemplate: batch.JobTemplateSpec{ - Spec: batch.JobSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - Status: batch.ScheduledJobStatus{ - Active: []api.ObjectReference{{Name: "ref"}}, - }, - }, - }, - ResourceGroup: batch.GroupName, - } - receivedScheduledJob, err := c.Setup(t).Batch().ScheduledJobs(ns).UpdateStatus(requestScheduledJob) - defer c.Close() - c.Validate(t, receivedScheduledJob, err) -} - -func TestDeleteScheduledJob(t *testing.T) { - // scheduled jobs should be tested only when batch/v2alpha1 is enabled - if *testapi.Batch.GroupVersion() != v2alpha1.SchemeGroupVersion { - return - } - - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{ - Method: "DELETE", - Path: testapi.Batch.ResourcePath(getScheduledJobsResource(), ns, "foo"), - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{StatusCode: 200}, - ResourceGroup: batch.GroupName, - } - err := c.Setup(t).Batch().ScheduledJobs(ns).Delete("foo", nil) - defer c.Close() - c.Validate(t, nil, err) -} - -func TestCreateScheduledJob(t *testing.T) { - // scheduled jobs should be tested only when batch/v2alpha1 is enabled - if *testapi.Batch.GroupVersion() != v2alpha1.SchemeGroupVersion { - return - } - - ns := api.NamespaceDefault - requestScheduledJob := &batch.ScheduledJob{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Batch.ResourcePath(getScheduledJobsResource(), ns, ""), - Body: requestScheduledJob, - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &batch.ScheduledJob{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: batch.ScheduledJobSpec{ - JobTemplate: batch.JobTemplateSpec{ - Spec: batch.JobSpec{ - Template: api.PodTemplateSpec{}, - }, - }, - }, - }, - }, - ResourceGroup: batch.GroupName, - } - receivedScheduledJob, err := c.Setup(t).Batch().ScheduledJobs(ns).Create(requestScheduledJob) - defer c.Close() - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - c.Validate(t, receivedScheduledJob, err) -} diff --git a/pkg/client/unversioned/secrets.go b/pkg/client/unversioned/secrets.go deleted file mode 100644 index bba3fd9369549..0000000000000 --- a/pkg/client/unversioned/secrets.go +++ /dev/null @@ -1,120 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -type SecretsNamespacer interface { - Secrets(namespace string) SecretsInterface -} - -type SecretsInterface interface { - Create(secret *api.Secret) (*api.Secret, error) - Update(secret *api.Secret) (*api.Secret, error) - Delete(name string) error - List(opts api.ListOptions) (*api.SecretList, error) - Get(name string) (*api.Secret, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// events implements Secrets interface -type secrets struct { - client *Client - namespace string -} - -// newSecrets returns a new secrets object. -func newSecrets(c *Client, ns string) *secrets { - return &secrets{ - client: c, - namespace: ns, - } -} - -func (s *secrets) Create(secret *api.Secret) (*api.Secret, error) { - result := &api.Secret{} - err := s.client.Post(). - Namespace(s.namespace). - Resource("secrets"). - Body(secret). - Do(). - Into(result) - - return result, err -} - -// List returns a list of secrets matching the selectors. -func (s *secrets) List(opts api.ListOptions) (*api.SecretList, error) { - result := &api.SecretList{} - - err := s.client.Get(). - Namespace(s.namespace). - Resource("secrets"). - VersionedParams(&opts, api.ParameterCodec). - Do(). - Into(result) - - return result, err -} - -// Get returns the given secret, or an error. -func (s *secrets) Get(name string) (*api.Secret, error) { - result := &api.Secret{} - err := s.client.Get(). - Namespace(s.namespace). - Resource("secrets"). - Name(name). - Do(). - Into(result) - - return result, err -} - -// Watch starts watching for secrets matching the given selectors. -func (s *secrets) Watch(opts api.ListOptions) (watch.Interface, error) { - return s.client.Get(). - Prefix("watch"). - Namespace(s.namespace). - Resource("secrets"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -func (s *secrets) Delete(name string) error { - return s.client.Delete(). - Namespace(s.namespace). - Resource("secrets"). - Name(name). - Do(). - Error() -} - -func (s *secrets) Update(secret *api.Secret) (result *api.Secret, err error) { - result = &api.Secret{} - err = s.client.Put(). - Namespace(s.namespace). - Resource("secrets"). - Name(secret.Name). - Body(secret). - Do(). - Into(result) - - return -} diff --git a/pkg/client/unversioned/service_accounts.go b/pkg/client/unversioned/service_accounts.go deleted file mode 100644 index 68d1b2112a25d..0000000000000 --- a/pkg/client/unversioned/service_accounts.go +++ /dev/null @@ -1,120 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -type ServiceAccountsNamespacer interface { - ServiceAccounts(namespace string) ServiceAccountsInterface -} - -type ServiceAccountsInterface interface { - Create(serviceAccount *api.ServiceAccount) (*api.ServiceAccount, error) - Update(serviceAccount *api.ServiceAccount) (*api.ServiceAccount, error) - Delete(name string) error - List(opts api.ListOptions) (*api.ServiceAccountList, error) - Get(name string) (*api.ServiceAccount, error) - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// serviceAccounts implements ServiceAccounts interface -type serviceAccounts struct { - client *Client - namespace string -} - -// newServiceAccounts returns a new serviceAccounts object. -func newServiceAccounts(c *Client, ns string) ServiceAccountsInterface { - return &serviceAccounts{ - client: c, - namespace: ns, - } -} - -func (s *serviceAccounts) Create(serviceAccount *api.ServiceAccount) (*api.ServiceAccount, error) { - result := &api.ServiceAccount{} - err := s.client.Post(). - Namespace(s.namespace). - Resource("serviceAccounts"). - Body(serviceAccount). - Do(). - Into(result) - - return result, err -} - -// List returns a list of serviceAccounts matching the selectors. -func (s *serviceAccounts) List(opts api.ListOptions) (*api.ServiceAccountList, error) { - result := &api.ServiceAccountList{} - - err := s.client.Get(). - Namespace(s.namespace). - Resource("serviceAccounts"). - VersionedParams(&opts, api.ParameterCodec). - Do(). - Into(result) - - return result, err -} - -// Get returns the given serviceAccount, or an error. -func (s *serviceAccounts) Get(name string) (*api.ServiceAccount, error) { - result := &api.ServiceAccount{} - err := s.client.Get(). - Namespace(s.namespace). - Resource("serviceAccounts"). - Name(name). - Do(). - Into(result) - - return result, err -} - -// Watch starts watching for serviceAccounts matching the given selectors. -func (s *serviceAccounts) Watch(opts api.ListOptions) (watch.Interface, error) { - return s.client.Get(). - Prefix("watch"). - Namespace(s.namespace). - Resource("serviceAccounts"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -func (s *serviceAccounts) Delete(name string) error { - return s.client.Delete(). - Namespace(s.namespace). - Resource("serviceAccounts"). - Name(name). - Do(). - Error() -} - -func (s *serviceAccounts) Update(serviceAccount *api.ServiceAccount) (result *api.ServiceAccount, err error) { - result = &api.ServiceAccount{} - err = s.client.Put(). - Namespace(s.namespace). - Resource("serviceAccounts"). - Name(serviceAccount.Name). - Body(serviceAccount). - Do(). - Into(result) - - return -} diff --git a/pkg/client/unversioned/services.go b/pkg/client/unversioned/services.go deleted file mode 100644 index aada5c164a62b..0000000000000 --- a/pkg/client/unversioned/services.go +++ /dev/null @@ -1,121 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/client/restclient" - "k8s.io/kubernetes/pkg/util/net" - "k8s.io/kubernetes/pkg/watch" -) - -// ServicesNamespacer has methods to work with Service resources in a namespace -type ServicesNamespacer interface { - Services(namespace string) ServiceInterface -} - -// ServiceInterface has methods to work with Service resources. -type ServiceInterface interface { - List(opts api.ListOptions) (*api.ServiceList, error) - Get(name string) (*api.Service, error) - Create(srv *api.Service) (*api.Service, error) - Update(srv *api.Service) (*api.Service, error) - UpdateStatus(srv *api.Service) (*api.Service, error) - Delete(name string) error - Watch(opts api.ListOptions) (watch.Interface, error) - ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper -} - -// services implements ServicesNamespacer interface -type services struct { - r *Client - ns string -} - -// newServices returns a services -func newServices(c *Client, namespace string) *services { - return &services{c, namespace} -} - -// List takes a selector, and returns the list of services that match that selector -func (c *services) List(opts api.ListOptions) (result *api.ServiceList, err error) { - result = &api.ServiceList{} - err = c.r.Get(). - Namespace(c.ns). - Resource("services"). - VersionedParams(&opts, api.ParameterCodec). - Do(). - Into(result) - return -} - -// Get returns information about a particular service. -func (c *services) Get(name string) (result *api.Service, err error) { - result = &api.Service{} - err = c.r.Get().Namespace(c.ns).Resource("services").Name(name).Do().Into(result) - return -} - -// Create creates a new service. -func (c *services) Create(svc *api.Service) (result *api.Service, err error) { - result = &api.Service{} - err = c.r.Post().Namespace(c.ns).Resource("services").Body(svc).Do().Into(result) - return -} - -// Update updates an existing service. -func (c *services) Update(svc *api.Service) (result *api.Service, err error) { - result = &api.Service{} - err = c.r.Put().Namespace(c.ns).Resource("services").Name(svc.Name).Body(svc).Do().Into(result) - return -} - -// UpdateStatus takes a Service object with the new status and applies it as an update to the existing Service. -func (c *services) UpdateStatus(service *api.Service) (result *api.Service, err error) { - result = &api.Service{} - err = c.r.Put().Namespace(c.ns).Resource("services").Name(service.Name).SubResource("status").Body(service).Do().Into(result) - return -} - -// Delete deletes an existing service. -func (c *services) Delete(name string) error { - return c.r.Delete().Namespace(c.ns).Resource("services").Name(name).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested services. -func (c *services) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Namespace(c.ns). - Resource("services"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} - -// ProxyGet returns a response of the service by calling it through the proxy. -func (c *services) ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper { - request := c.r.Get(). - Namespace(c.ns). - Resource("services"). - SubResource("proxy"). - Name(net.JoinSchemeNamePort(scheme, name, port)). - Suffix(path) - for k, v := range params { - request = request.Param(k, v) - } - return request -} diff --git a/pkg/client/unversioned/services_test.go b/pkg/client/unversioned/services_test.go deleted file mode 100644 index 8038d2dea2c2a..0000000000000 --- a/pkg/client/unversioned/services_test.go +++ /dev/null @@ -1,239 +0,0 @@ -/* -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 unversioned_test - -import ( - "net/url" - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/apimachinery/registered" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" - "k8s.io/kubernetes/pkg/labels" -) - -func TestListServices(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath("services", ns, ""), - Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, - Body: &api.ServiceList{ - Items: []api.Service{ - { - ObjectMeta: api.ObjectMeta{ - Name: "name", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: api.ServiceSpec{ - Selector: map[string]string{ - "one": "two", - }, - }, - }, - }, - }, - }, - } - receivedServiceList, err := c.Setup(t).Services(ns).List(api.ListOptions{}) - defer c.Close() - t.Logf("received services: %v %#v", err, receivedServiceList) - c.Validate(t, receivedServiceList, err) -} - -func TestListServicesLabels(t *testing.T) { - ns := api.NamespaceDefault - labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(registered.GroupOrDie(api.GroupName).GroupVersion.String()) - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath("services", ns, ""), - Query: simple.BuildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})}, - Response: simple.Response{StatusCode: 200, - Body: &api.ServiceList{ - Items: []api.Service{ - { - ObjectMeta: api.ObjectMeta{ - Name: "name", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: api.ServiceSpec{ - Selector: map[string]string{ - "one": "two", - }, - }, - }, - }, - }, - }, - } - c.Setup(t) - defer c.Close() - c.QueryValidator[labelSelectorQueryParamName] = simple.ValidateLabels - selector := labels.Set{"foo": "bar", "name": "baz"}.AsSelector() - options := api.ListOptions{LabelSelector: selector} - receivedServiceList, err := c.Services(ns).List(options) - c.Validate(t, receivedServiceList, err) -} - -func TestGetService(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath("services", ns, "1"), - Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}}, - } - response, err := c.Setup(t).Services(ns).Get("1") - defer c.Close() - c.Validate(t, response, err) -} - -func TestGetServiceWithNoName(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{Error: true} - receivedPod, err := c.Setup(t).Services(ns).Get("") - defer c.Close() - if (err != nil) && (err.Error() != simple.NameRequiredError) { - t.Errorf("Expected error: %v, but got %v", simple.NameRequiredError, err) - } - - c.Validate(t, receivedPod, err) -} - -func TestCreateService(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{ - Method: "POST", - Path: testapi.Default.ResourcePath("services", ns, ""), - Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}, - Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}}, - } - response, err := c.Setup(t).Services(ns).Create(&api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}) - defer c.Close() - c.Validate(t, response, err) -} - -func TestUpdateService(t *testing.T) { - ns := api.NamespaceDefault - svc := &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1", ResourceVersion: "1"}} - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Default.ResourcePath("services", ns, "service-1"), Body: svc, Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200, Body: svc}, - } - response, err := c.Setup(t).Services(ns).Update(svc) - defer c.Close() - c.Validate(t, response, err) -} - -func TestDeleteService(t *testing.T) { - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Default.ResourcePath("services", ns, "1"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).Services(ns).Delete("1") - defer c.Close() - c.Validate(t, nil, err) -} - -func TestUpdateServiceStatus(t *testing.T) { - ns := api.NamespaceDefault - lbStatus := api.LoadBalancerStatus{ - Ingress: []api.LoadBalancerIngress{ - {IP: "127.0.0.1"}, - }, - } - requestService := &api.Service{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Namespace: ns, - ResourceVersion: "1", - }, - Status: api.ServiceStatus{ - LoadBalancer: lbStatus, - }, - } - c := &simple.Client{ - Request: simple.Request{ - Method: "PUT", - Path: testapi.Default.ResourcePath("services", ns, "foo") + "/status", - Query: simple.BuildQueryValues(nil), - }, - Response: simple.Response{ - StatusCode: 200, - Body: &api.Service{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Spec: api.ServiceSpec{}, - Status: api.ServiceStatus{ - LoadBalancer: lbStatus, - }, - }, - }, - } - receivedService, err := c.Setup(t).Services(ns).UpdateStatus(requestService) - defer c.Close() - c.Validate(t, receivedService, err) -} - -func TestServiceProxyGet(t *testing.T) { - body := "OK" - ns := api.NamespaceDefault - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath("services", ns, "service-1") + "/proxy/foo", - Query: simple.BuildQueryValues(url.Values{"param-name": []string{"param-value"}}), - }, - Response: simple.Response{StatusCode: 200, RawBody: &body}, - } - response, err := c.Setup(t).Services(ns).ProxyGet("", "service-1", "", "foo", map[string]string{"param-name": "param-value"}).DoRaw() - defer c.Close() - c.ValidateRaw(t, response, err) - - // With scheme and port specified - c = &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Default.ResourcePath("services", ns, "https:service-1:my-port") + "/proxy/foo", - Query: simple.BuildQueryValues(url.Values{"param-name": []string{"param-value"}}), - }, - Response: simple.Response{StatusCode: 200, RawBody: &body}, - } - response, err = c.Setup(t).Services(ns).ProxyGet("https", "service-1", "my-port", "foo", map[string]string{"param-name": "param-value"}).DoRaw() - defer c.Close() - c.ValidateRaw(t, response, err) -} diff --git a/pkg/client/unversioned/storage.go b/pkg/client/unversioned/storage.go deleted file mode 100644 index 3b8d2b76f57cb..0000000000000 --- a/pkg/client/unversioned/storage.go +++ /dev/null @@ -1,77 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apimachinery/registered" - "k8s.io/kubernetes/pkg/apis/storage" - "k8s.io/kubernetes/pkg/client/restclient" -) - -type StorageInterface interface { - StorageClassesInterface -} - -// StorageClient is used to interact with Kubernetes storage features. -type StorageClient struct { - *restclient.RESTClient -} - -func (c *StorageClient) StorageClasses() StorageClassInterface { - return newStorageClasses(c) -} - -func NewStorage(c *restclient.Config) (*StorageClient, error) { - config := *c - if err := setStorageDefaults(&config); err != nil { - return nil, err - } - client, err := restclient.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &StorageClient{client}, nil -} - -func NewStorageOrDie(c *restclient.Config) *StorageClient { - client, err := NewStorage(c) - if err != nil { - panic(err) - } - return client -} - -func setStorageDefaults(config *restclient.Config) error { - // if storage group is not registered, return an error - g, err := registered.Group(storage.GroupName) - if err != nil { - return err - } - config.APIPath = defaultAPIPath - if config.UserAgent == "" { - config.UserAgent = restclient.DefaultKubernetesUserAgent() - } - // TODO: Unconditionally set the config.Version, until we fix the config. - //if config.Version == "" { - copyGroupVersion := g.GroupVersion - config.GroupVersion = ©GroupVersion - //} - - config.NegotiatedSerializer = api.Codecs - return nil -} diff --git a/pkg/client/unversioned/storageclasses.go b/pkg/client/unversioned/storageclasses.go deleted file mode 100644 index 509e540a66a94..0000000000000 --- a/pkg/client/unversioned/storageclasses.go +++ /dev/null @@ -1,87 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/storage" - "k8s.io/kubernetes/pkg/watch" -) - -type StorageClassesInterface interface { - StorageClasses() StorageClassInterface -} - -// StorageClassInterface has methods to work with StorageClass resources. -type StorageClassInterface interface { - List(opts api.ListOptions) (*storage.StorageClassList, error) - Get(name string) (*storage.StorageClass, error) - Create(storageClass *storage.StorageClass) (*storage.StorageClass, error) - Update(storageClass *storage.StorageClass) (*storage.StorageClass, error) - Delete(name string) error - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// storageClasses implements StorageClassInterface -type storageClasses struct { - client *StorageClient -} - -func newStorageClasses(c *StorageClient) *storageClasses { - return &storageClasses{c} -} - -func (c *storageClasses) List(opts api.ListOptions) (result *storage.StorageClassList, err error) { - result = &storage.StorageClassList{} - err = c.client.Get(). - Resource("storageclasses"). - VersionedParams(&opts, api.ParameterCodec). - Do(). - Into(result) - - return result, err -} - -func (c *storageClasses) Get(name string) (result *storage.StorageClass, err error) { - result = &storage.StorageClass{} - err = c.client.Get().Resource("storageClasses").Name(name).Do().Into(result) - return -} - -func (c *storageClasses) Create(storageClass *storage.StorageClass) (result *storage.StorageClass, err error) { - result = &storage.StorageClass{} - err = c.client.Post().Resource("storageClasses").Body(storageClass).Do().Into(result) - return -} - -func (c *storageClasses) Update(storageClass *storage.StorageClass) (result *storage.StorageClass, err error) { - result = &storage.StorageClass{} - err = c.client.Put().Resource("storageClasses").Name(storageClass.Name).Body(storageClass).Do().Into(result) - return -} - -func (c *storageClasses) Delete(name string) error { - return c.client.Delete().Resource("storageClasses").Name(name).Do().Error() -} - -func (c *storageClasses) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.client.Get(). - Prefix("watch"). - Resource("storageClasses"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/storageclasses_test.go b/pkg/client/unversioned/storageclasses_test.go deleted file mode 100644 index 27a85a4b396d8..0000000000000 --- a/pkg/client/unversioned/storageclasses_test.go +++ /dev/null @@ -1,147 +0,0 @@ -/* -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 unversioned_test - -import ( - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/apis/storage" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getStorageClassResourceName() string { - return "storageclasses" -} - -func TestListStorageClasses(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Storage.ResourcePath(getStorageClassResourceName(), "", ""), - }, - Response: simple.Response{StatusCode: 200, - Body: &storage.StorageClassList{ - Items: []storage.StorageClass{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Provisioner: "aaa", - }, - }, - }, - }, - } - receivedSCList, err := c.Setup(t).Storage().StorageClasses().List(api.ListOptions{}) - c.Validate(t, receivedSCList, err) -} - -func TestGetStorageClass(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{Method: "GET", Path: testapi.Storage.ResourcePath(getStorageClassResourceName(), "", "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &storage.StorageClass{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Provisioner: "aaa", - }, - }, - } - receivedSC, err := c.Setup(t).Storage().StorageClasses().Get("foo") - c.Validate(t, receivedSC, err) -} - -func TestGetStorageClassWithNoName(t *testing.T) { - c := &simple.Client{Error: true} - receivedSC, err := c.Setup(t).Storage().StorageClasses().Get("") - if (err != nil) && (err.Error() != simple.NameRequiredError) { - t.Errorf("Expected error: %v, but got %v", simple.NameRequiredError, err) - } - - c.Validate(t, receivedSC, err) -} - -func TestUpdateStorageClass(t *testing.T) { - requestSC := &storage.StorageClass{ - ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - Provisioner: "aaa", - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Storage.ResourcePath(getStorageClassResourceName(), "", "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &storage.StorageClass{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Provisioner: "aaa", - }, - }, - } - receivedSC, err := c.Setup(t).Storage().StorageClasses().Update(requestSC) - c.Validate(t, receivedSC, err) -} - -func TestDeleteStorageClass(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Storage.ResourcePath(getStorageClassResourceName(), "", "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).Storage().StorageClasses().Delete("foo") - c.Validate(t, nil, err) -} - -func TestCreateStorageClass(t *testing.T) { - requestSC := &storage.StorageClass{ - ObjectMeta: api.ObjectMeta{Name: "foo"}, - Provisioner: "aaa", - } - c := &simple.Client{ - Request: simple.Request{Method: "POST", Path: testapi.Storage.ResourcePath(getStorageClassResourceName(), "", ""), Body: requestSC, Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &storage.StorageClass{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Provisioner: "aaa", - }, - }, - } - receivedSC, err := c.Setup(t).Storage().StorageClasses().Create(requestSC) - c.Validate(t, receivedSC, err) -} diff --git a/pkg/client/unversioned/subjectaccessreview.go b/pkg/client/unversioned/subjectaccessreview.go deleted file mode 100644 index b7a2c59e67a9e..0000000000000 --- a/pkg/client/unversioned/subjectaccessreview.go +++ /dev/null @@ -1,45 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/apis/authorization" -) - -type SubjectAccessReviewsInterface interface { - SubjectAccessReviews() SubjectAccessReviewInterface -} - -type SubjectAccessReviewInterface interface { - Create(subjectAccessReview *authorization.SubjectAccessReview) (*authorization.SubjectAccessReview, error) -} - -type subjectAccessReviews struct { - client *AuthorizationClient -} - -func newSubjectAccessReviews(c *AuthorizationClient) *subjectAccessReviews { - return &subjectAccessReviews{ - client: c, - } -} - -func (c *subjectAccessReviews) Create(subjectAccessReview *authorization.SubjectAccessReview) (result *authorization.SubjectAccessReview, err error) { - result = &authorization.SubjectAccessReview{} - err = c.client.Post().Resource("subjectAccessReviews").Body(subjectAccessReview).Do().Into(result) - return -} diff --git a/pkg/client/unversioned/testclient/BUILD b/pkg/client/unversioned/testclient/BUILD deleted file mode 100644 index 25e0c801b3eb6..0000000000000 --- a/pkg/client/unversioned/testclient/BUILD +++ /dev/null @@ -1,102 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -load( - "@io_bazel_rules_go//go:def.bzl", - "go_binary", - "go_library", - "go_test", - "cgo_library", -) - -go_library( - name = "go_default_library", - srcs = [ - "actions.go", - "fake_certificates.go", - "fake_clusterrolebindings.go", - "fake_clusterroles.go", - "fake_componentstatuses.go", - "fake_configmaps.go", - "fake_daemon_sets.go", - "fake_deployments.go", - "fake_endpoints.go", - "fake_events.go", - "fake_horizontal_pod_autoscalers.go", - "fake_ingress.go", - "fake_jobs.go", - "fake_limit_ranges.go", - "fake_namespaces.go", - "fake_network_policies.go", - "fake_nodes.go", - "fake_persistent_volume_claims.go", - "fake_persistent_volumes.go", - "fake_petsets.go", - "fake_pod_templates.go", - "fake_pods.go", - "fake_podsecuritypolicy.go", - "fake_replica_sets.go", - "fake_replication_controllers.go", - "fake_resource_quotas.go", - "fake_rolebindings.go", - "fake_roles.go", - "fake_scales.go", - "fake_scheduledjobs.go", - "fake_secrets.go", - "fake_service_accounts.go", - "fake_services.go", - "fake_storage_classes.go", - "fake_subjectaccessreviews.go", - "fake_thirdpartyresources.go", - "fake_tokenreviews.go", - "fixture.go", - "testclient.go", - ], - tags = ["automanaged"], - deps = [ - "//pkg/api:go_default_library", - "//pkg/api/errors:go_default_library", - "//pkg/api/meta:go_default_library", - "//pkg/api/unversioned:go_default_library", - "//pkg/api/v1:go_default_library", - "//pkg/apimachinery/registered:go_default_library", - "//pkg/apis/apps:go_default_library", - "//pkg/apis/authentication:go_default_library", - "//pkg/apis/authorization:go_default_library", - "//pkg/apis/autoscaling:go_default_library", - "//pkg/apis/batch:go_default_library", - "//pkg/apis/certificates:go_default_library", - "//pkg/apis/extensions:go_default_library", - "//pkg/apis/rbac:go_default_library", - "//pkg/apis/storage:go_default_library", - "//pkg/client/restclient:go_default_library", - "//pkg/client/typed/discovery:go_default_library", - "//pkg/client/unversioned:go_default_library", - "//pkg/fields:go_default_library", - "//pkg/labels:go_default_library", - "//pkg/runtime:go_default_library", - "//pkg/util/yaml:go_default_library", - "//pkg/version:go_default_library", - "//pkg/watch:go_default_library", - "//vendor:github.com/emicklei/go-restful/swagger", - ], -) - -go_test( - name = "go_default_test", - srcs = [ - "fake_test.go", - "testclient_test.go", - ], - data = ["//examples:config"], - library = "go_default_library", - tags = ["automanaged"], - deps = [ - "//pkg/api:go_default_library", - "//pkg/api/errors:go_default_library", - "//pkg/api/testapi:go_default_library", - "//pkg/client/unversioned:go_default_library", - "//pkg/runtime:go_default_library", - ], -) diff --git a/pkg/client/unversioned/testclient/actions.go b/pkg/client/unversioned/testclient/actions.go deleted file mode 100644 index 15769e69d1319..0000000000000 --- a/pkg/client/unversioned/testclient/actions.go +++ /dev/null @@ -1,446 +0,0 @@ -/* -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 testclient - -import ( - "strings" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/runtime" -) - -func NewRootGetAction(resource, name string) GetActionImpl { - action := GetActionImpl{} - action.Verb = "get" - action.Resource = resource - action.Name = name - - return action -} - -func NewGetAction(resource, namespace, name string) GetActionImpl { - action := GetActionImpl{} - action.Verb = "get" - action.Resource = resource - action.Namespace = namespace - action.Name = name - - return action -} - -func NewRootListAction(resource string, 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, 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 string, object runtime.Object) CreateActionImpl { - action := CreateActionImpl{} - action.Verb = "create" - action.Resource = resource - action.Object = object - - return action -} - -func NewCreateAction(resource, namespace string, object runtime.Object) CreateActionImpl { - action := CreateActionImpl{} - action.Verb = "create" - action.Resource = resource - action.Namespace = namespace - action.Object = object - - return action -} - -func NewRootUpdateAction(resource string, object runtime.Object) UpdateActionImpl { - action := UpdateActionImpl{} - action.Verb = "update" - action.Resource = resource - action.Object = object - - return action -} - -func NewUpdateAction(resource, namespace string, object runtime.Object) UpdateActionImpl { - action := UpdateActionImpl{} - action.Verb = "update" - action.Resource = resource - action.Namespace = namespace - action.Object = object - - return action -} - -func NewRootPatchAction(resource string, object runtime.Object) PatchActionImpl { - action := PatchActionImpl{} - action.Verb = "patch" - action.Resource = resource - action.Object = object - - return action -} - -func NewPatchAction(resource, namespace string, object runtime.Object) PatchActionImpl { - action := PatchActionImpl{} - action.Verb = "patch" - action.Resource = resource - action.Namespace = namespace - action.Object = object - - return action -} - -func NewUpdateSubresourceAction(resource, subresource, 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, name string) DeleteActionImpl { - action := DeleteActionImpl{} - action.Verb = "delete" - action.Resource = resource - action.Name = name - - return action -} - -func NewDeleteAction(resource, namespace, name string) DeleteActionImpl { - action := DeleteActionImpl{} - action.Verb = "delete" - action.Resource = resource - action.Namespace = namespace - action.Name = name - - return action -} - -func NewRootDeleteCollectionAction(resource string, 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, 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 string, 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, 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, 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() string - GetSubresource() string - Matches(verb, resource string) bool -} - -type GenericAction interface { - Action - GetValue() interface{} -} - -type GetAction interface { - Action - GetName() string -} - -type ListAction interface { - Action - GetListRestrictions() ListRestrictions -} - -type CreateAction interface { - Action - GetObject() runtime.Object -} - -type UpdateAction interface { - Action - GetObject() runtime.Object -} - -type DeleteAction interface { - Action - GetName() string -} - -type WatchAction interface { - Action - GetWatchRestrictions() WatchRestrictions -} - -type ProxyGetAction interface { - Action - GetScheme() string - GetName() string - GetPort() string - GetPath() string - GetParams() map[string]string -} - -type ActionImpl struct { - Namespace string - Verb string - Resource string - Subresource string -} - -func (a ActionImpl) GetNamespace() string { - return a.Namespace -} -func (a ActionImpl) GetVerb() string { - return a.Verb -} -func (a ActionImpl) GetResource() string { - return a.Resource -} -func (a ActionImpl) GetSubresource() string { - return a.Subresource -} -func (a ActionImpl) Matches(verb, resource string) bool { - return strings.ToLower(verb) == strings.ToLower(a.Verb) && - strings.ToLower(resource) == strings.ToLower(a.Resource) -} - -type GenericActionImpl struct { - ActionImpl - Value interface{} -} - -func (a GenericActionImpl) GetValue() interface{} { - return a.Value -} - -type GetActionImpl struct { - ActionImpl - Name string -} - -func (a GetActionImpl) GetName() string { - return a.Name -} - -type ListActionImpl struct { - ActionImpl - ListRestrictions ListRestrictions -} - -func (a ListActionImpl) GetListRestrictions() ListRestrictions { - return a.ListRestrictions -} - -type CreateActionImpl struct { - ActionImpl - Object runtime.Object -} - -func (a CreateActionImpl) GetObject() runtime.Object { - return a.Object -} - -type UpdateActionImpl struct { - ActionImpl - Object runtime.Object -} - -func (a UpdateActionImpl) GetObject() runtime.Object { - return a.Object -} - -type PatchActionImpl struct { - ActionImpl - Object runtime.Object -} - -func (a PatchActionImpl) GetObject() runtime.Object { - return a.Object -} - -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 -} diff --git a/pkg/client/unversioned/testclient/fake_certificates.go b/pkg/client/unversioned/testclient/fake_certificates.go deleted file mode 100644 index 6278decdf8aba..0000000000000 --- a/pkg/client/unversioned/testclient/fake_certificates.go +++ /dev/null @@ -1,107 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/certificates" - "k8s.io/kubernetes/pkg/client/unversioned" - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/watch" -) - -// NewSimpleFakeCertificate returns a client that will respond with the provided objects -func NewSimpleFakeCertificates(objects ...runtime.Object) *FakeCertificates { - return &FakeCertificates{Fake: NewSimpleFake(objects...)} -} - -// FakeCertificates implements CertificatesInterface. 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 FakeCertificates struct { - *Fake -} - -func (c *FakeCertificates) CertificateSigningRequests() unversioned.CertificateSigningRequestInterface { - return &FakeCertificateSigningRequest{Fake: c} -} - -// FakeCertificateSigningRequest implements CertificateSigningRequestInterface -type FakeCertificateSigningRequest struct { - Fake *FakeCertificates -} - -func (c *FakeCertificateSigningRequest) Get(name string) (*certificates.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(NewRootGetAction("certificatesigningrequests", name), &certificates.CertificateSigningRequest{}) - if obj == nil { - return nil, err - } - - return obj.(*certificates.CertificateSigningRequest), err -} - -func (c *FakeCertificateSigningRequest) List(opts api.ListOptions) (*certificates.CertificateSigningRequestList, error) { - obj, err := c.Fake.Invokes(NewRootListAction("certificatesigningrequests", opts), &certificates.CertificateSigningRequestList{}) - if obj == nil { - return nil, err - } - - return obj.(*certificates.CertificateSigningRequestList), err -} - -func (c *FakeCertificateSigningRequest) Create(csr *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(NewRootCreateAction("certificatesigningrequests", csr), csr) - if obj == nil { - return nil, err - } - - return obj.(*certificates.CertificateSigningRequest), err -} - -func (c *FakeCertificateSigningRequest) Update(csr *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(NewRootUpdateAction("certificatesigningrequests", csr), csr) - if obj == nil { - return nil, err - } - - return obj.(*certificates.CertificateSigningRequest), err -} - -func (c *FakeCertificateSigningRequest) UpdateStatus(csr *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("certificatesigningrequests", "status", api.NamespaceAll, csr), csr) - if obj == nil { - return nil, err - } - return obj.(*certificates.CertificateSigningRequest), err -} - -func (c *FakeCertificateSigningRequest) UpdateApproval(csr *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("certificatesigningrequests", "approval", api.NamespaceAll, csr), csr) - if obj == nil { - return nil, err - } - return obj.(*certificates.CertificateSigningRequest), err -} - -func (c *FakeCertificateSigningRequest) Delete(name string, opts *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewRootDeleteAction("certificatesigningrequests", name), &certificates.CertificateSigningRequest{}) - return err -} - -func (c *FakeCertificateSigningRequest) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewRootWatchAction("certificatesigningrequests", opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_clusterrolebindings.go b/pkg/client/unversioned/testclient/fake_clusterrolebindings.go deleted file mode 100644 index 0e9d2413e6caa..0000000000000 --- a/pkg/client/unversioned/testclient/fake_clusterrolebindings.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/rbac" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeClusterRoleBindings implements ClusterRoleBindingInterface -type FakeClusterRoleBindings struct { - Fake *FakeRbac -} - -func (c *FakeClusterRoleBindings) Get(name string) (*rbac.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(NewRootGetAction("clusterrolebindings", name), &rbac.ClusterRoleBinding{}) - if obj == nil { - return nil, err - } - - return obj.(*rbac.ClusterRoleBinding), err -} - -func (c *FakeClusterRoleBindings) List(opts api.ListOptions) (*rbac.ClusterRoleBindingList, error) { - obj, err := c.Fake.Invokes(NewRootListAction("clusterrolebindings", opts), &rbac.ClusterRoleBindingList{}) - if obj == nil { - return nil, err - } - - return obj.(*rbac.ClusterRoleBindingList), err -} - -func (c *FakeClusterRoleBindings) Create(csr *rbac.ClusterRoleBinding) (*rbac.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(NewRootCreateAction("clusterrolebindings", csr), csr) - if obj == nil { - return nil, err - } - - return obj.(*rbac.ClusterRoleBinding), err -} - -func (c *FakeClusterRoleBindings) Update(csr *rbac.ClusterRoleBinding) (*rbac.ClusterRoleBinding, error) { - obj, err := c.Fake.Invokes(NewRootUpdateAction("clusterrolebindings", csr), csr) - if obj == nil { - return nil, err - } - - return obj.(*rbac.ClusterRoleBinding), err -} - -func (c *FakeClusterRoleBindings) Delete(name string, opts *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewRootDeleteAction("clusterrolebindings", name), &rbac.ClusterRoleBinding{}) - return err -} - -func (c *FakeClusterRoleBindings) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewRootWatchAction("clusterrolebindings", opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_clusterroles.go b/pkg/client/unversioned/testclient/fake_clusterroles.go deleted file mode 100644 index 5735224a75114..0000000000000 --- a/pkg/client/unversioned/testclient/fake_clusterroles.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/rbac" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeClusterRoles implements ClusterRoleInterface -type FakeClusterRoles struct { - Fake *FakeRbac -} - -func (c *FakeClusterRoles) Get(name string) (*rbac.ClusterRole, error) { - obj, err := c.Fake.Invokes(NewRootGetAction("clusterroles", name), &rbac.ClusterRole{}) - if obj == nil { - return nil, err - } - - return obj.(*rbac.ClusterRole), err -} - -func (c *FakeClusterRoles) List(opts api.ListOptions) (*rbac.ClusterRoleList, error) { - obj, err := c.Fake.Invokes(NewRootListAction("clusterroles", opts), &rbac.ClusterRoleList{}) - if obj == nil { - return nil, err - } - - return obj.(*rbac.ClusterRoleList), err -} - -func (c *FakeClusterRoles) Create(csr *rbac.ClusterRole) (*rbac.ClusterRole, error) { - obj, err := c.Fake.Invokes(NewRootCreateAction("clusterroles", csr), csr) - if obj == nil { - return nil, err - } - - return obj.(*rbac.ClusterRole), err -} - -func (c *FakeClusterRoles) Update(csr *rbac.ClusterRole) (*rbac.ClusterRole, error) { - obj, err := c.Fake.Invokes(NewRootUpdateAction("clusterroles", csr), csr) - if obj == nil { - return nil, err - } - - return obj.(*rbac.ClusterRole), err -} - -func (c *FakeClusterRoles) Delete(name string, opts *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewRootDeleteAction("clusterroles", name), &rbac.ClusterRole{}) - return err -} - -func (c *FakeClusterRoles) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewRootWatchAction("clusterroles", opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_componentstatuses.go b/pkg/client/unversioned/testclient/fake_componentstatuses.go deleted file mode 100644 index 06bbdf8d2b008..0000000000000 --- a/pkg/client/unversioned/testclient/fake_componentstatuses.go +++ /dev/null @@ -1,44 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" -) - -// Fake implements ComponentStatusInterface. -type FakeComponentStatuses struct { - Fake *Fake -} - -func (c *FakeComponentStatuses) Get(name string) (*api.ComponentStatus, error) { - obj, err := c.Fake.Invokes(NewRootGetAction("componentstatuses", name), &api.ComponentStatus{}) - if obj == nil { - return nil, err - } - - return obj.(*api.ComponentStatus), err -} - -func (c *FakeComponentStatuses) List(opts api.ListOptions) (result *api.ComponentStatusList, err error) { - obj, err := c.Fake.Invokes(NewRootListAction("componentstatuses", opts), &api.ComponentStatusList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.ComponentStatusList), err -} diff --git a/pkg/client/unversioned/testclient/fake_configmaps.go b/pkg/client/unversioned/testclient/fake_configmaps.go deleted file mode 100644 index 7a35b28ab4f4c..0000000000000 --- a/pkg/client/unversioned/testclient/fake_configmaps.go +++ /dev/null @@ -1,78 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -const ( - configMapResourceName string = "configMaps" -) - -// FakeConfigMaps implements ConfigMapInterface. 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 FakeConfigMaps struct { - Fake *Fake - Namespace string -} - -func (c *FakeConfigMaps) Get(name string) (*api.ConfigMap, error) { - obj, err := c.Fake.Invokes(NewGetAction(configMapResourceName, c.Namespace, name), &api.ConfigMap{}) - if obj == nil { - return nil, err - } - - return obj.(*api.ConfigMap), err -} - -func (c *FakeConfigMaps) List(opts api.ListOptions) (*api.ConfigMapList, error) { - obj, err := c.Fake.Invokes(NewListAction(configMapResourceName, c.Namespace, opts), &api.ConfigMapList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.ConfigMapList), err -} - -func (c *FakeConfigMaps) Create(cfg *api.ConfigMap) (*api.ConfigMap, error) { - obj, err := c.Fake.Invokes(NewCreateAction(configMapResourceName, c.Namespace, cfg), cfg) - if obj == nil { - return nil, err - } - - return obj.(*api.ConfigMap), err -} - -func (c *FakeConfigMaps) Update(cfg *api.ConfigMap) (*api.ConfigMap, error) { - obj, err := c.Fake.Invokes(NewUpdateAction(configMapResourceName, c.Namespace, cfg), cfg) - if obj == nil { - return nil, err - } - - return obj.(*api.ConfigMap), err -} - -func (c *FakeConfigMaps) Delete(name string) error { - _, err := c.Fake.Invokes(NewDeleteAction(configMapResourceName, c.Namespace, name), &api.ConfigMap{}) - return err -} - -func (c *FakeConfigMaps) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction(configMapResourceName, c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_daemon_sets.go b/pkg/client/unversioned/testclient/fake_daemon_sets.go deleted file mode 100644 index ec0c88850aa66..0000000000000 --- a/pkg/client/unversioned/testclient/fake_daemon_sets.go +++ /dev/null @@ -1,83 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - kclientlib "k8s.io/kubernetes/pkg/client/unversioned" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeDaemonSet implements DaemonInterface. 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 FakeDaemonSets struct { - Fake *FakeExperimental - Namespace string -} - -// Ensure statically that FakeDaemonSets implements DaemonInterface. -var _ kclientlib.DaemonSetInterface = &FakeDaemonSets{} - -func (c *FakeDaemonSets) Get(name string) (*extensions.DaemonSet, error) { - obj, err := c.Fake.Invokes(NewGetAction("daemonsets", c.Namespace, name), &extensions.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.DaemonSet), err -} - -func (c *FakeDaemonSets) List(opts api.ListOptions) (*extensions.DaemonSetList, error) { - obj, err := c.Fake.Invokes(NewListAction("daemonsets", c.Namespace, opts), &extensions.DaemonSetList{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.DaemonSetList), err -} - -func (c *FakeDaemonSets) Create(daemon *extensions.DaemonSet) (*extensions.DaemonSet, error) { - obj, err := c.Fake.Invokes(NewCreateAction("daemonsets", c.Namespace, daemon), &extensions.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.DaemonSet), err -} - -func (c *FakeDaemonSets) Update(daemon *extensions.DaemonSet) (*extensions.DaemonSet, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("daemonsets", c.Namespace, daemon), &extensions.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.DaemonSet), err -} - -func (c *FakeDaemonSets) UpdateStatus(daemon *extensions.DaemonSet) (*extensions.DaemonSet, error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("daemonsets", "status", c.Namespace, daemon), &extensions.DaemonSet{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.DaemonSet), err -} - -func (c *FakeDaemonSets) Delete(name string) error { - _, err := c.Fake.Invokes(NewDeleteAction("daemonsets", c.Namespace, name), &extensions.DaemonSet{}) - return err -} - -func (c *FakeDaemonSets) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("daemonsets", c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_deployments.go b/pkg/client/unversioned/testclient/fake_deployments.go deleted file mode 100644 index 7c4c10b30292c..0000000000000 --- a/pkg/client/unversioned/testclient/fake_deployments.go +++ /dev/null @@ -1,109 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - kclientlib "k8s.io/kubernetes/pkg/client/unversioned" - "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeDeployments implements DeploymentInterface. Meant to be embedded into a struct to get a default -// implementation. This makes faking out just the methods you want to test easier. -type FakeDeployments struct { - Fake *FakeExperimental - Namespace string -} - -// Ensure statically that FakeDeployments implements DeploymentInterface. -var _ kclientlib.DeploymentInterface = &FakeDeployments{} - -func (c *FakeDeployments) Get(name string) (*extensions.Deployment, error) { - obj, err := c.Fake.Invokes(NewGetAction("deployments", c.Namespace, name), &extensions.Deployment{}) - if obj == nil { - return nil, err - } - - return obj.(*extensions.Deployment), err -} - -func (c *FakeDeployments) List(opts api.ListOptions) (*extensions.DeploymentList, error) { - obj, err := c.Fake.Invokes(NewListAction("deployments", c.Namespace, opts), &extensions.DeploymentList{}) - if obj == nil { - return nil, err - } - label := opts.LabelSelector - if label == nil { - label = labels.Everything() - } - list := &extensions.DeploymentList{} - for _, deployment := range obj.(*extensions.DeploymentList).Items { - if label.Matches(labels.Set(deployment.Labels)) { - list.Items = append(list.Items, deployment) - } - } - return list, err -} - -func (c *FakeDeployments) Create(deployment *extensions.Deployment) (*extensions.Deployment, error) { - obj, err := c.Fake.Invokes(NewCreateAction("deployments", c.Namespace, deployment), deployment) - if obj == nil { - return nil, err - } - - return obj.(*extensions.Deployment), err -} - -func (c *FakeDeployments) Update(deployment *extensions.Deployment) (*extensions.Deployment, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("deployments", c.Namespace, deployment), deployment) - if obj == nil { - return nil, err - } - - return obj.(*extensions.Deployment), err -} - -func (c *FakeDeployments) UpdateStatus(deployment *extensions.Deployment) (*extensions.Deployment, error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("deployments", "status", c.Namespace, deployment), deployment) - if obj == nil { - return nil, err - } - - return obj.(*extensions.Deployment), err -} - -func (c *FakeDeployments) Delete(name string, options *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("deployments", c.Namespace, name), &extensions.Deployment{}) - return err -} - -func (c *FakeDeployments) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("deployments", c.Namespace, opts)) -} - -func (c *FakeDeployments) Rollback(deploymentRollback *extensions.DeploymentRollback) error { - action := CreateActionImpl{} - action.Verb = "create" - action.Resource = "deployments" - action.Subresource = "rollback" - action.Object = deploymentRollback - - _, err := c.Fake.Invokes(action, deploymentRollback) - return err -} diff --git a/pkg/client/unversioned/testclient/fake_endpoints.go b/pkg/client/unversioned/testclient/fake_endpoints.go deleted file mode 100644 index dda3456afa133..0000000000000 --- a/pkg/client/unversioned/testclient/fake_endpoints.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeEndpoints implements EndpointInterface. 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 FakeEndpoints struct { - Fake *Fake - Namespace string -} - -func (c *FakeEndpoints) Get(name string) (*api.Endpoints, error) { - obj, err := c.Fake.Invokes(NewGetAction("endpoints", c.Namespace, name), &api.Endpoints{}) - if obj == nil { - return nil, err - } - - return obj.(*api.Endpoints), err -} - -func (c *FakeEndpoints) List(opts api.ListOptions) (*api.EndpointsList, error) { - obj, err := c.Fake.Invokes(NewListAction("endpoints", c.Namespace, opts), &api.EndpointsList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.EndpointsList), err -} - -func (c *FakeEndpoints) Create(endpoints *api.Endpoints) (*api.Endpoints, error) { - obj, err := c.Fake.Invokes(NewCreateAction("endpoints", c.Namespace, endpoints), endpoints) - if obj == nil { - return nil, err - } - - return obj.(*api.Endpoints), err -} - -func (c *FakeEndpoints) Update(endpoints *api.Endpoints) (*api.Endpoints, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("endpoints", c.Namespace, endpoints), endpoints) - if obj == nil { - return nil, err - } - - return obj.(*api.Endpoints), err -} - -func (c *FakeEndpoints) Delete(name string) error { - _, err := c.Fake.Invokes(NewDeleteAction("endpoints", c.Namespace, name), &api.Endpoints{}) - return err -} - -func (c *FakeEndpoints) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("endpoints", c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_events.go b/pkg/client/unversioned/testclient/fake_events.go deleted file mode 100644 index 7c3ee3be69ca6..0000000000000 --- a/pkg/client/unversioned/testclient/fake_events.go +++ /dev/null @@ -1,151 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/fields" - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeEvents implements EventInterface. 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 FakeEvents struct { - Fake *Fake - Namespace string -} - -// Get returns the given event, or an error. -func (c *FakeEvents) Get(name string) (*api.Event, error) { - action := NewRootGetAction("events", name) - if c.Namespace != "" { - action = NewGetAction("events", c.Namespace, name) - } - obj, err := c.Fake.Invokes(action, &api.Event{}) - if obj == nil { - return nil, err - } - - return obj.(*api.Event), err -} - -// List returns a list of events matching the selectors. -func (c *FakeEvents) List(opts api.ListOptions) (*api.EventList, error) { - action := NewRootListAction("events", opts) - if c.Namespace != "" { - action = NewListAction("events", c.Namespace, opts) - } - obj, err := c.Fake.Invokes(action, &api.EventList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.EventList), err -} - -// Create makes a new event. Returns the copy of the event the server returns, or an error. -func (c *FakeEvents) Create(event *api.Event) (*api.Event, error) { - action := NewRootCreateAction("events", event) - if c.Namespace != "" { - action = NewCreateAction("events", c.Namespace, event) - } - obj, err := c.Fake.Invokes(action, event) - if obj == nil { - return nil, err - } - - return obj.(*api.Event), err -} - -// Update replaces an existing event. Returns the copy of the event the server returns, or an error. -func (c *FakeEvents) Update(event *api.Event) (*api.Event, error) { - action := NewRootUpdateAction("events", event) - if c.Namespace != "" { - action = NewUpdateAction("events", c.Namespace, event) - } - obj, err := c.Fake.Invokes(action, event) - if obj == nil { - return nil, err - } - - return obj.(*api.Event), err -} - -// Patch patches an existing event. Returns the copy of the event the server returns, or an error. -func (c *FakeEvents) Patch(event *api.Event, data []byte) (*api.Event, error) { - action := NewRootPatchAction("events", event) - if c.Namespace != "" { - action = NewPatchAction("events", c.Namespace, event) - } - obj, err := c.Fake.Invokes(action, event) - if obj == nil { - return nil, err - } - - return obj.(*api.Event), err -} - -func (c *FakeEvents) Delete(name string) error { - action := NewRootDeleteAction("events", name) - if c.Namespace != "" { - action = NewDeleteAction("events", c.Namespace, name) - } - _, err := c.Fake.Invokes(action, &api.Event{}) - return err -} - -func (c *FakeEvents) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { - action := NewRootDeleteCollectionAction("events", listOptions) - if c.Namespace != "" { - action = NewDeleteCollectionAction("events", c.Namespace, listOptions) - } - _, err := c.Fake.Invokes(action, &api.EventList{}) - return err -} - -// Watch starts watching for events matching the given selectors. -func (c *FakeEvents) Watch(opts api.ListOptions) (watch.Interface, error) { - action := NewRootWatchAction("events", opts) - if c.Namespace != "" { - action = NewWatchAction("events", c.Namespace, opts) - } - return c.Fake.InvokesWatch(action) -} - -// Search returns a list of events matching the specified object. -func (c *FakeEvents) Search(objOrRef runtime.Object) (*api.EventList, error) { - action := NewRootListAction("events", api.ListOptions{}) - if c.Namespace != "" { - action = NewListAction("events", c.Namespace, api.ListOptions{}) - } - obj, err := c.Fake.Invokes(action, &api.EventList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.EventList), err -} - -func (c *FakeEvents) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector { - action := GenericActionImpl{} - action.Verb = "get-field-selector" - action.Resource = "events" - - c.Fake.Invokes(action, nil) - return fields.Everything() -} diff --git a/pkg/client/unversioned/testclient/fake_horizontal_pod_autoscalers.go b/pkg/client/unversioned/testclient/fake_horizontal_pod_autoscalers.go deleted file mode 100644 index 9c3805f8f75b1..0000000000000 --- a/pkg/client/unversioned/testclient/fake_horizontal_pod_autoscalers.go +++ /dev/null @@ -1,93 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/autoscaling" - "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeHorizontalPodAutoscalers implements HorizontalPodAutoscalerInterface. Meant to be embedded into a struct to get a default -// implementation. This makes faking out just the methods you want to test easier. -type FakeHorizontalPodAutoscalers struct { - Fake *FakeAutoscaling - Namespace string -} - -func (c *FakeHorizontalPodAutoscalers) Get(name string) (*autoscaling.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(NewGetAction("horizontalpodautoscalers", c.Namespace, name), &autoscaling.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - - return obj.(*autoscaling.HorizontalPodAutoscaler), err -} - -func (c *FakeHorizontalPodAutoscalers) List(opts api.ListOptions) (*autoscaling.HorizontalPodAutoscalerList, error) { - obj, err := c.Fake.Invokes(NewListAction("horizontalpodautoscalers", c.Namespace, opts), &autoscaling.HorizontalPodAutoscalerList{}) - if obj == nil { - return nil, err - } - label := opts.LabelSelector - if label == nil { - label = labels.Everything() - } - list := &autoscaling.HorizontalPodAutoscalerList{} - for _, a := range obj.(*autoscaling.HorizontalPodAutoscalerList).Items { - if label.Matches(labels.Set(a.Labels)) { - list.Items = append(list.Items, a) - } - } - return list, err -} - -func (c *FakeHorizontalPodAutoscalers) Create(a *autoscaling.HorizontalPodAutoscaler) (*autoscaling.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(NewCreateAction("horizontalpodautoscalers", c.Namespace, a), a) - if obj == nil { - return nil, err - } - - return obj.(*autoscaling.HorizontalPodAutoscaler), err -} - -func (c *FakeHorizontalPodAutoscalers) Update(a *autoscaling.HorizontalPodAutoscaler) (*autoscaling.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("horizontalpodautoscalers", c.Namespace, a), a) - if obj == nil { - return nil, err - } - - return obj.(*autoscaling.HorizontalPodAutoscaler), err -} - -func (c *FakeHorizontalPodAutoscalers) UpdateStatus(a *autoscaling.HorizontalPodAutoscaler) (*autoscaling.HorizontalPodAutoscaler, error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("horizontalpodautoscalers", "status", c.Namespace, a), &autoscaling.HorizontalPodAutoscaler{}) - if obj == nil { - return nil, err - } - return obj.(*autoscaling.HorizontalPodAutoscaler), err -} - -func (c *FakeHorizontalPodAutoscalers) Delete(name string, options *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("horizontalpodautoscalers", c.Namespace, name), &autoscaling.HorizontalPodAutoscaler{}) - return err -} - -func (c *FakeHorizontalPodAutoscalers) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("horizontalpodautoscalers", c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_ingress.go b/pkg/client/unversioned/testclient/fake_ingress.go deleted file mode 100644 index da2b41115f67f..0000000000000 --- a/pkg/client/unversioned/testclient/fake_ingress.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeIngress implements IngressInterface. 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 FakeIngress struct { - Fake *FakeExperimental - Namespace string -} - -func (c *FakeIngress) Get(name string) (*extensions.Ingress, error) { - obj, err := c.Fake.Invokes(NewGetAction("ingresses", c.Namespace, name), &extensions.Ingress{}) - if obj == nil { - return nil, err - } - - return obj.(*extensions.Ingress), err -} - -func (c *FakeIngress) List(opts api.ListOptions) (*extensions.IngressList, error) { - obj, err := c.Fake.Invokes(NewListAction("ingresses", c.Namespace, opts), &extensions.IngressList{}) - if obj == nil { - return nil, err - } - - return obj.(*extensions.IngressList), err -} - -func (c *FakeIngress) Create(ingress *extensions.Ingress) (*extensions.Ingress, error) { - obj, err := c.Fake.Invokes(NewCreateAction("ingresses", c.Namespace, ingress), ingress) - if obj == nil { - return nil, err - } - - return obj.(*extensions.Ingress), err -} - -func (c *FakeIngress) Update(ingress *extensions.Ingress) (*extensions.Ingress, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("ingresses", c.Namespace, ingress), ingress) - if obj == nil { - return nil, err - } - - return obj.(*extensions.Ingress), err -} - -func (c *FakeIngress) Delete(name string, options *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("ingresses", c.Namespace, name), &extensions.Ingress{}) - return err -} - -func (c *FakeIngress) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("ingresses", c.Namespace, opts)) -} - -func (c *FakeIngress) UpdateStatus(ingress *extensions.Ingress) (result *extensions.Ingress, err error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("ingresses", "status", c.Namespace, ingress), ingress) - if obj == nil { - return nil, err - } - - return obj.(*extensions.Ingress), err -} diff --git a/pkg/client/unversioned/testclient/fake_jobs.go b/pkg/client/unversioned/testclient/fake_jobs.go deleted file mode 100644 index bbcbdf6620876..0000000000000 --- a/pkg/client/unversioned/testclient/fake_jobs.go +++ /dev/null @@ -1,147 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/batch" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeJobs implements JobInterface. 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 FakeJobs struct { - Fake *FakeExperimental - Namespace string -} - -func (c *FakeJobs) Get(name string) (*batch.Job, error) { - obj, err := c.Fake.Invokes(NewGetAction("jobs", c.Namespace, name), &batch.Job{}) - if obj == nil { - return nil, err - } - - return obj.(*batch.Job), err -} - -func (c *FakeJobs) List(opts api.ListOptions) (*batch.JobList, error) { - obj, err := c.Fake.Invokes(NewListAction("jobs", c.Namespace, opts), &batch.JobList{}) - if obj == nil { - return nil, err - } - - return obj.(*batch.JobList), err -} - -func (c *FakeJobs) Create(job *batch.Job) (*batch.Job, error) { - obj, err := c.Fake.Invokes(NewCreateAction("jobs", c.Namespace, job), job) - if obj == nil { - return nil, err - } - - return obj.(*batch.Job), err -} - -func (c *FakeJobs) Update(job *batch.Job) (*batch.Job, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("jobs", c.Namespace, job), job) - if obj == nil { - return nil, err - } - - return obj.(*batch.Job), err -} - -func (c *FakeJobs) Delete(name string, options *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("jobs", c.Namespace, name), &batch.Job{}) - return err -} - -func (c *FakeJobs) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("jobs", c.Namespace, opts)) -} - -func (c *FakeJobs) UpdateStatus(job *batch.Job) (result *batch.Job, err error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("jobs", "status", c.Namespace, job), job) - if obj == nil { - return nil, err - } - - return obj.(*batch.Job), err -} - -// FakeJobs implements JobInterface. Meant to be embedded into a struct to get a default -// implementation. This makes faking out just the methods you want to test easier. -// This is a test implementation of JobsV1 -// TODO(piosz): get back to one client implementation once HPA will be graduated to GA completely -type FakeJobsV1 struct { - Fake *FakeBatch - Namespace string -} - -func (c *FakeJobsV1) Get(name string) (*batch.Job, error) { - obj, err := c.Fake.Invokes(NewGetAction("jobs", c.Namespace, name), &batch.Job{}) - if obj == nil { - return nil, err - } - - return obj.(*batch.Job), err -} - -func (c *FakeJobsV1) List(opts api.ListOptions) (*batch.JobList, error) { - obj, err := c.Fake.Invokes(NewListAction("jobs", c.Namespace, opts), &batch.JobList{}) - if obj == nil { - return nil, err - } - - return obj.(*batch.JobList), err -} - -func (c *FakeJobsV1) Create(job *batch.Job) (*batch.Job, error) { - obj, err := c.Fake.Invokes(NewCreateAction("jobs", c.Namespace, job), job) - if obj == nil { - return nil, err - } - - return obj.(*batch.Job), err -} - -func (c *FakeJobsV1) Update(job *batch.Job) (*batch.Job, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("jobs", c.Namespace, job), job) - if obj == nil { - return nil, err - } - - return obj.(*batch.Job), err -} - -func (c *FakeJobsV1) Delete(name string, options *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("jobs", c.Namespace, name), &batch.Job{}) - return err -} - -func (c *FakeJobsV1) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("jobs", c.Namespace, opts)) -} - -func (c *FakeJobsV1) UpdateStatus(job *batch.Job) (result *batch.Job, err error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("jobs", "status", c.Namespace, job), job) - if obj == nil { - return nil, err - } - - return obj.(*batch.Job), err -} diff --git a/pkg/client/unversioned/testclient/fake_limit_ranges.go b/pkg/client/unversioned/testclient/fake_limit_ranges.go deleted file mode 100644 index 2520933240ac4..0000000000000 --- a/pkg/client/unversioned/testclient/fake_limit_ranges.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeLimitRanges implements PodsInterface. Meant to be embedded into a struct to get a default -// implementation. This makes faking out just the methods you want to test easier. -type FakeLimitRanges struct { - Fake *Fake - Namespace string -} - -func (c *FakeLimitRanges) Get(name string) (*api.LimitRange, error) { - obj, err := c.Fake.Invokes(NewGetAction("limitranges", c.Namespace, name), &api.LimitRange{}) - if obj == nil { - return nil, err - } - - return obj.(*api.LimitRange), err -} - -func (c *FakeLimitRanges) List(opts api.ListOptions) (*api.LimitRangeList, error) { - obj, err := c.Fake.Invokes(NewListAction("limitranges", c.Namespace, opts), &api.LimitRangeList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.LimitRangeList), err -} - -func (c *FakeLimitRanges) Create(limitRange *api.LimitRange) (*api.LimitRange, error) { - obj, err := c.Fake.Invokes(NewCreateAction("limitranges", c.Namespace, limitRange), limitRange) - if obj == nil { - return nil, err - } - - return obj.(*api.LimitRange), err -} - -func (c *FakeLimitRanges) Update(limitRange *api.LimitRange) (*api.LimitRange, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("limitranges", c.Namespace, limitRange), limitRange) - if obj == nil { - return nil, err - } - - return obj.(*api.LimitRange), err -} - -func (c *FakeLimitRanges) Delete(name string) error { - _, err := c.Fake.Invokes(NewDeleteAction("limitranges", c.Namespace, name), &api.LimitRange{}) - return err -} - -func (c *FakeLimitRanges) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("limitranges", c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_namespaces.go b/pkg/client/unversioned/testclient/fake_namespaces.go deleted file mode 100644 index 45c9246561ac5..0000000000000 --- a/pkg/client/unversioned/testclient/fake_namespaces.go +++ /dev/null @@ -1,103 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeNamespaces implements NamespacesInterface. Meant to be embedded into a struct to get a default -// implementation. This makes faking out just the methods you want to test easier. -type FakeNamespaces struct { - Fake *Fake -} - -func (c *FakeNamespaces) Get(name string) (*api.Namespace, error) { - obj, err := c.Fake.Invokes(NewRootGetAction("namespaces", name), &api.Namespace{}) - if obj == nil { - return nil, err - } - - return obj.(*api.Namespace), err -} - -func (c *FakeNamespaces) List(opts api.ListOptions) (*api.NamespaceList, error) { - obj, err := c.Fake.Invokes(NewRootListAction("namespaces", opts), &api.NamespaceList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.NamespaceList), err -} - -func (c *FakeNamespaces) Create(namespace *api.Namespace) (*api.Namespace, error) { - obj, err := c.Fake.Invokes(NewRootCreateAction("namespaces", namespace), namespace) - if obj == nil { - return nil, err - } - - return obj.(*api.Namespace), err -} - -func (c *FakeNamespaces) Update(namespace *api.Namespace) (*api.Namespace, error) { - obj, err := c.Fake.Invokes(NewRootUpdateAction("namespaces", namespace), namespace) - if obj == nil { - return nil, err - } - - return obj.(*api.Namespace), err -} - -func (c *FakeNamespaces) Delete(name string) error { - _, err := c.Fake.Invokes(NewRootDeleteAction("namespaces", name), &api.Namespace{}) - return err -} - -func (c *FakeNamespaces) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewRootWatchAction("namespaces", opts)) -} - -func (c *FakeNamespaces) Finalize(namespace *api.Namespace) (*api.Namespace, error) { - action := CreateActionImpl{} - action.Verb = "create" - action.Resource = "namespaces" - action.Subresource = "finalize" - action.Object = namespace - - obj, err := c.Fake.Invokes(action, namespace) - if obj == nil { - return nil, err - } - - return obj.(*api.Namespace), err -} - -func (c *FakeNamespaces) Status(namespace *api.Namespace) (*api.Namespace, error) { - action := CreateActionImpl{} - action.Verb = "create" - action.Resource = "namespaces" - action.Subresource = "status" - action.Object = namespace - - obj, err := c.Fake.Invokes(action, namespace) - if obj == nil { - return nil, err - } - - return obj.(*api.Namespace), err -} diff --git a/pkg/client/unversioned/testclient/fake_network_policies.go b/pkg/client/unversioned/testclient/fake_network_policies.go deleted file mode 100644 index 5239be9a1e27b..0000000000000 --- a/pkg/client/unversioned/testclient/fake_network_policies.go +++ /dev/null @@ -1,75 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - kclientlib "k8s.io/kubernetes/pkg/client/unversioned" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeNetworkPolicies implements NetworkPolicyInterface. 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 FakeNetworkPolicies struct { - Fake *FakeExperimental - Namespace string -} - -// Ensure statically that FakeNetworkPolicies implements NetworkPolicyInterface. -var _ kclientlib.NetworkPolicyInterface = &FakeNetworkPolicies{} - -func (c *FakeNetworkPolicies) Get(name string) (*extensions.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(NewGetAction("networkpolicies", c.Namespace, name), &extensions.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.NetworkPolicy), err -} - -func (c *FakeNetworkPolicies) List(opts api.ListOptions) (*extensions.NetworkPolicyList, error) { - obj, err := c.Fake.Invokes(NewListAction("networkpolicies", c.Namespace, opts), &extensions.NetworkPolicyList{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.NetworkPolicyList), err -} - -func (c *FakeNetworkPolicies) Create(np *extensions.NetworkPolicy) (*extensions.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(NewCreateAction("networkpolicies", c.Namespace, np), &extensions.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.NetworkPolicy), err -} - -func (c *FakeNetworkPolicies) Update(np *extensions.NetworkPolicy) (*extensions.NetworkPolicy, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("networkpolicies", c.Namespace, np), &extensions.NetworkPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.NetworkPolicy), err -} - -func (c *FakeNetworkPolicies) Delete(name string, options *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("networkpolicies", c.Namespace, name), &extensions.NetworkPolicy{}) - return err -} - -func (c *FakeNetworkPolicies) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("networkpolicies", c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_nodes.go b/pkg/client/unversioned/testclient/fake_nodes.go deleted file mode 100644 index d03882fb979e7..0000000000000 --- a/pkg/client/unversioned/testclient/fake_nodes.go +++ /dev/null @@ -1,93 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeNodes implements NodeInterface. 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 FakeNodes struct { - Fake *Fake -} - -func (c *FakeNodes) Get(name string) (*api.Node, error) { - obj, err := c.Fake.Invokes(NewRootGetAction("nodes", name), &api.Node{}) - if obj == nil { - return nil, err - } - - return obj.(*api.Node), err -} - -func (c *FakeNodes) List(opts api.ListOptions) (*api.NodeList, error) { - obj, err := c.Fake.Invokes(NewRootListAction("nodes", opts), &api.NodeList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.NodeList), err -} - -func (c *FakeNodes) Create(node *api.Node) (*api.Node, error) { - obj, err := c.Fake.Invokes(NewRootCreateAction("nodes", node), node) - if obj == nil { - return nil, err - } - - return obj.(*api.Node), err -} - -func (c *FakeNodes) Update(node *api.Node) (*api.Node, error) { - obj, err := c.Fake.Invokes(NewRootUpdateAction("nodes", node), node) - if obj == nil { - return nil, err - } - - return obj.(*api.Node), err -} - -func (c *FakeNodes) Delete(name string) error { - _, err := c.Fake.Invokes(NewRootDeleteAction("nodes", name), &api.Node{}) - return err -} - -func (c *FakeNodes) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { - _, err := c.Fake.Invokes(NewRootDeleteCollectionAction("nodes", listOptions), &api.NodeList{}) - return err -} - -func (c *FakeNodes) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewRootWatchAction("nodes", opts)) -} - -func (c *FakeNodes) UpdateStatus(node *api.Node) (*api.Node, error) { - action := CreateActionImpl{} - action.Verb = "update" - action.Resource = "nodes" - action.Subresource = "status" - action.Object = node - - obj, err := c.Fake.Invokes(action, node) - if obj == nil { - return nil, err - } - - return obj.(*api.Node), err -} diff --git a/pkg/client/unversioned/testclient/fake_persistent_volume_claims.go b/pkg/client/unversioned/testclient/fake_persistent_volume_claims.go deleted file mode 100644 index 6eb092ff7135b..0000000000000 --- a/pkg/client/unversioned/testclient/fake_persistent_volume_claims.go +++ /dev/null @@ -1,81 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -type FakePersistentVolumeClaims struct { - Fake *Fake - Namespace string -} - -func (c *FakePersistentVolumeClaims) Get(name string) (*api.PersistentVolumeClaim, error) { - obj, err := c.Fake.Invokes(NewGetAction("persistentvolumeclaims", c.Namespace, name), &api.PersistentVolumeClaim{}) - if obj == nil { - return nil, err - } - - return obj.(*api.PersistentVolumeClaim), err -} - -func (c *FakePersistentVolumeClaims) List(opts api.ListOptions) (*api.PersistentVolumeClaimList, error) { - obj, err := c.Fake.Invokes(NewListAction("persistentvolumeclaims", c.Namespace, opts), &api.PersistentVolumeClaimList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.PersistentVolumeClaimList), err -} - -func (c *FakePersistentVolumeClaims) Create(claim *api.PersistentVolumeClaim) (*api.PersistentVolumeClaim, error) { - obj, err := c.Fake.Invokes(NewCreateAction("persistentvolumeclaims", c.Namespace, claim), claim) - if obj == nil { - return nil, err - } - - return obj.(*api.PersistentVolumeClaim), err -} - -func (c *FakePersistentVolumeClaims) Update(claim *api.PersistentVolumeClaim) (*api.PersistentVolumeClaim, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("persistentvolumeclaims", c.Namespace, claim), claim) - if obj == nil { - return nil, err - } - - return obj.(*api.PersistentVolumeClaim), err -} - -func (c *FakePersistentVolumeClaims) Delete(name string) error { - _, err := c.Fake.Invokes(NewDeleteAction("persistentvolumeclaims", c.Namespace, name), &api.PersistentVolumeClaim{}) - return err -} - -func (c *FakePersistentVolumeClaims) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("persistentvolumeclaims", c.Namespace, opts)) -} - -func (c *FakePersistentVolumeClaims) UpdateStatus(claim *api.PersistentVolumeClaim) (*api.PersistentVolumeClaim, error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("persistentvolumeclaims", "status", c.Namespace, claim), claim) - if obj == nil { - return nil, err - } - - return obj.(*api.PersistentVolumeClaim), err -} diff --git a/pkg/client/unversioned/testclient/fake_persistent_volumes.go b/pkg/client/unversioned/testclient/fake_persistent_volumes.go deleted file mode 100644 index d17d351f059ca..0000000000000 --- a/pkg/client/unversioned/testclient/fake_persistent_volumes.go +++ /dev/null @@ -1,86 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -type FakePersistentVolumes struct { - Fake *Fake -} - -func (c *FakePersistentVolumes) Get(name string) (*api.PersistentVolume, error) { - obj, err := c.Fake.Invokes(NewRootGetAction("persistentvolumes", name), &api.PersistentVolume{}) - if obj == nil { - return nil, err - } - - return obj.(*api.PersistentVolume), err -} - -func (c *FakePersistentVolumes) List(opts api.ListOptions) (*api.PersistentVolumeList, error) { - obj, err := c.Fake.Invokes(NewRootListAction("persistentvolumes", opts), &api.PersistentVolumeList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.PersistentVolumeList), err -} - -func (c *FakePersistentVolumes) Create(pv *api.PersistentVolume) (*api.PersistentVolume, error) { - obj, err := c.Fake.Invokes(NewRootCreateAction("persistentvolumes", pv), pv) - if obj == nil { - return nil, err - } - - return obj.(*api.PersistentVolume), err -} - -func (c *FakePersistentVolumes) Update(pv *api.PersistentVolume) (*api.PersistentVolume, error) { - obj, err := c.Fake.Invokes(NewRootUpdateAction("persistentvolumes", pv), pv) - if obj == nil { - return nil, err - } - - return obj.(*api.PersistentVolume), err -} - -func (c *FakePersistentVolumes) Delete(name string) error { - _, err := c.Fake.Invokes(NewRootDeleteAction("persistentvolumes", name), &api.PersistentVolume{}) - return err -} - -func (c *FakePersistentVolumes) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewRootWatchAction("persistentvolumes", opts)) -} - -func (c *FakePersistentVolumes) UpdateStatus(pv *api.PersistentVolume) (*api.PersistentVolume, error) { - action := UpdateActionImpl{} - action.Verb = "update" - action.Resource = "persistentvolumes" - action.Subresource = "status" - action.Object = pv - - obj, err := c.Fake.Invokes(action, pv) - if obj == nil { - return nil, err - } - - return obj.(*api.PersistentVolume), err -} diff --git a/pkg/client/unversioned/testclient/fake_petsets.go b/pkg/client/unversioned/testclient/fake_petsets.go deleted file mode 100644 index 192ffba2b252c..0000000000000 --- a/pkg/client/unversioned/testclient/fake_petsets.go +++ /dev/null @@ -1,83 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/apps" - "k8s.io/kubernetes/pkg/watch" -) - -// FakePetSets implements PetSetsInterface. 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 FakePetSets struct { - Fake *FakeApps - Namespace string -} - -func (c *FakePetSets) Get(name string) (*apps.PetSet, error) { - obj, err := c.Fake.Invokes(NewGetAction("petsets", c.Namespace, name), &apps.PetSet{}) - if obj == nil { - return nil, err - } - - return obj.(*apps.PetSet), err -} - -func (c *FakePetSets) List(opts api.ListOptions) (*apps.PetSetList, error) { - obj, err := c.Fake.Invokes(NewListAction("petsets", c.Namespace, opts), &apps.PetSetList{}) - if obj == nil { - return nil, err - } - return obj.(*apps.PetSetList), err -} - -func (c *FakePetSets) Create(rs *apps.PetSet) (*apps.PetSet, error) { - obj, err := c.Fake.Invokes(NewCreateAction("petsets", c.Namespace, rs), rs) - if obj == nil { - return nil, err - } - - return obj.(*apps.PetSet), err -} - -func (c *FakePetSets) Update(rs *apps.PetSet) (*apps.PetSet, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("petsets", c.Namespace, rs), rs) - if obj == nil { - return nil, err - } - - return obj.(*apps.PetSet), err -} - -func (c *FakePetSets) Delete(name string, options *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("petsets", c.Namespace, name), &apps.PetSet{}) - return err -} - -func (c *FakePetSets) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("petsets", c.Namespace, opts)) -} - -func (c *FakePetSets) UpdateStatus(rs *apps.PetSet) (result *apps.PetSet, err error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("petsets", "status", c.Namespace, rs), rs) - if obj == nil { - return nil, err - } - - return obj.(*apps.PetSet), err -} diff --git a/pkg/client/unversioned/testclient/fake_pod_templates.go b/pkg/client/unversioned/testclient/fake_pod_templates.go deleted file mode 100644 index 83d74683522f1..0000000000000 --- a/pkg/client/unversioned/testclient/fake_pod_templates.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// FakePodTemplates implements PodTemplatesInterface. Meant to be embedded into a struct to get a default -// implementation. This makes faking out just the methods you want to test easier. -type FakePodTemplates struct { - Fake *Fake - Namespace string -} - -func (c *FakePodTemplates) Get(name string) (*api.PodTemplate, error) { - obj, err := c.Fake.Invokes(NewGetAction("podtemplates", c.Namespace, name), &api.PodTemplate{}) - if obj == nil { - return nil, err - } - - return obj.(*api.PodTemplate), err -} - -func (c *FakePodTemplates) List(opts api.ListOptions) (*api.PodTemplateList, error) { - obj, err := c.Fake.Invokes(NewListAction("podtemplates", c.Namespace, opts), &api.PodTemplateList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.PodTemplateList), err -} - -func (c *FakePodTemplates) Create(pod *api.PodTemplate) (*api.PodTemplate, error) { - obj, err := c.Fake.Invokes(NewCreateAction("podtemplates", c.Namespace, pod), pod) - if obj == nil { - return nil, err - } - - return obj.(*api.PodTemplate), err -} - -func (c *FakePodTemplates) Update(pod *api.PodTemplate) (*api.PodTemplate, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("podtemplates", c.Namespace, pod), pod) - if obj == nil { - return nil, err - } - - return obj.(*api.PodTemplate), err -} - -func (c *FakePodTemplates) Delete(name string, options *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("podtemplates", c.Namespace, name), &api.PodTemplate{}) - return err -} - -func (c *FakePodTemplates) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("podtemplates", c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_pods.go b/pkg/client/unversioned/testclient/fake_pods.go deleted file mode 100644 index ef45382b7aad8..0000000000000 --- a/pkg/client/unversioned/testclient/fake_pods.go +++ /dev/null @@ -1,117 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/client/restclient" - "k8s.io/kubernetes/pkg/labels" - "k8s.io/kubernetes/pkg/watch" -) - -// FakePods implements PodsInterface. Meant to be embedded into a struct to get a default -// implementation. This makes faking out just the methods you want to test easier. -type FakePods struct { - Fake *Fake - Namespace string -} - -func (c *FakePods) Get(name string) (*api.Pod, error) { - obj, err := c.Fake.Invokes(NewGetAction("pods", c.Namespace, name), &api.Pod{}) - if obj == nil { - return nil, err - } - - return obj.(*api.Pod), err -} - -func (c *FakePods) List(opts api.ListOptions) (*api.PodList, error) { - obj, err := c.Fake.Invokes(NewListAction("pods", c.Namespace, opts), &api.PodList{}) - if obj == nil { - return nil, err - } - label := opts.LabelSelector - if label == nil { - label = labels.Everything() - } - list := &api.PodList{} - for _, pod := range obj.(*api.PodList).Items { - if label.Matches(labels.Set(pod.Labels)) { - list.Items = append(list.Items, pod) - } - } - return list, err -} - -func (c *FakePods) Create(pod *api.Pod) (*api.Pod, error) { - obj, err := c.Fake.Invokes(NewCreateAction("pods", c.Namespace, pod), pod) - if obj == nil { - return nil, err - } - - return obj.(*api.Pod), err -} - -func (c *FakePods) Update(pod *api.Pod) (*api.Pod, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("pods", c.Namespace, pod), pod) - if obj == nil { - return nil, err - } - - return obj.(*api.Pod), err -} - -func (c *FakePods) Delete(name string, options *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("pods", c.Namespace, name), &api.Pod{}) - return err -} - -func (c *FakePods) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("pods", c.Namespace, opts)) -} - -func (c *FakePods) Bind(binding *api.Binding) error { - action := CreateActionImpl{} - action.Verb = "create" - action.Resource = "pods" - action.Subresource = "bindings" - action.Object = binding - - _, err := c.Fake.Invokes(action, binding) - return err -} - -func (c *FakePods) UpdateStatus(pod *api.Pod) (*api.Pod, error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("pods", "status", c.Namespace, pod), pod) - if obj == nil { - return nil, err - } - - return obj.(*api.Pod), err -} - -func (c *FakePods) GetLogs(name string, opts *api.PodLogOptions) *restclient.Request { - action := GenericActionImpl{} - action.Verb = "get" - action.Namespace = c.Namespace - action.Resource = "pod" - action.Subresource = "logs" - action.Value = opts - - _, _ = c.Fake.Invokes(action, &api.Pod{}) - return &restclient.Request{} -} diff --git a/pkg/client/unversioned/testclient/fake_podsecuritypolicy.go b/pkg/client/unversioned/testclient/fake_podsecuritypolicy.go deleted file mode 100644 index 33297b1a23f34..0000000000000 --- a/pkg/client/unversioned/testclient/fake_podsecuritypolicy.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/watch" -) - -// FakePodSecurityPolicy implements PodSecurityPolicyInterface. 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 FakePodSecurityPolicy struct { - Fake *Fake - Namespace string -} - -func (c *FakePodSecurityPolicy) List(opts api.ListOptions) (*extensions.PodSecurityPolicyList, error) { - obj, err := c.Fake.Invokes(NewListAction("podsecuritypolicies", c.Namespace, opts), &extensions.PodSecurityPolicyList{}) - if obj == nil { - return nil, err - } - - return obj.(*extensions.PodSecurityPolicyList), err -} - -func (c *FakePodSecurityPolicy) Get(name string) (*extensions.PodSecurityPolicy, error) { - obj, err := c.Fake.Invokes(NewGetAction("podsecuritypolicies", c.Namespace, name), &extensions.PodSecurityPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.PodSecurityPolicy), err -} - -func (c *FakePodSecurityPolicy) Create(psp *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error) { - obj, err := c.Fake.Invokes(NewCreateAction("podsecuritypolicies", c.Namespace, psp), &extensions.PodSecurityPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.PodSecurityPolicy), err -} - -func (c *FakePodSecurityPolicy) Update(psp *extensions.PodSecurityPolicy) (*extensions.PodSecurityPolicy, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("podsecuritypolicies", c.Namespace, psp), &extensions.PodSecurityPolicy{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.PodSecurityPolicy), err -} - -func (c *FakePodSecurityPolicy) Delete(name string) error { - _, err := c.Fake.Invokes(NewDeleteAction("podsecuritypolicies", c.Namespace, name), &extensions.PodSecurityPolicy{}) - return err -} - -func (c *FakePodSecurityPolicy) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("podsecuritypolicies", c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_replica_sets.go b/pkg/client/unversioned/testclient/fake_replica_sets.go deleted file mode 100644 index 174f9360db53f..0000000000000 --- a/pkg/client/unversioned/testclient/fake_replica_sets.go +++ /dev/null @@ -1,83 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeReplicaSets implements ReplicaSetsInterface. 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 FakeReplicaSets struct { - Fake *FakeExperimental - Namespace string -} - -func (c *FakeReplicaSets) Get(name string) (*extensions.ReplicaSet, error) { - obj, err := c.Fake.Invokes(NewGetAction("replicasets", c.Namespace, name), &extensions.ReplicaSet{}) - if obj == nil { - return nil, err - } - - return obj.(*extensions.ReplicaSet), err -} - -func (c *FakeReplicaSets) List(opts api.ListOptions) (*extensions.ReplicaSetList, error) { - obj, err := c.Fake.Invokes(NewListAction("replicasets", c.Namespace, opts), &extensions.ReplicaSetList{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.ReplicaSetList), err -} - -func (c *FakeReplicaSets) Create(rs *extensions.ReplicaSet) (*extensions.ReplicaSet, error) { - obj, err := c.Fake.Invokes(NewCreateAction("replicasets", c.Namespace, rs), rs) - if obj == nil { - return nil, err - } - - return obj.(*extensions.ReplicaSet), err -} - -func (c *FakeReplicaSets) Update(rs *extensions.ReplicaSet) (*extensions.ReplicaSet, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("replicasets", c.Namespace, rs), rs) - if obj == nil { - return nil, err - } - - return obj.(*extensions.ReplicaSet), err -} - -func (c *FakeReplicaSets) Delete(name string, options *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("replicasets", c.Namespace, name), &extensions.ReplicaSet{}) - return err -} - -func (c *FakeReplicaSets) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("replicasets", c.Namespace, opts)) -} - -func (c *FakeReplicaSets) UpdateStatus(rs *extensions.ReplicaSet) (result *extensions.ReplicaSet, err error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("replicasets", "status", c.Namespace, rs), rs) - if obj == nil { - return nil, err - } - - return obj.(*extensions.ReplicaSet), err -} diff --git a/pkg/client/unversioned/testclient/fake_replication_controllers.go b/pkg/client/unversioned/testclient/fake_replication_controllers.go deleted file mode 100644 index d56e4fcb304c0..0000000000000 --- a/pkg/client/unversioned/testclient/fake_replication_controllers.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeReplicationControllers implements ReplicationControllerInterface. 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 FakeReplicationControllers struct { - Fake *Fake - Namespace string -} - -func (c *FakeReplicationControllers) Get(name string) (*api.ReplicationController, error) { - obj, err := c.Fake.Invokes(NewGetAction("replicationcontrollers", c.Namespace, name), &api.ReplicationController{}) - if obj == nil { - return nil, err - } - - return obj.(*api.ReplicationController), err -} - -func (c *FakeReplicationControllers) List(opts api.ListOptions) (*api.ReplicationControllerList, error) { - obj, err := c.Fake.Invokes(NewListAction("replicationcontrollers", c.Namespace, opts), &api.ReplicationControllerList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.ReplicationControllerList), err -} - -func (c *FakeReplicationControllers) Create(controller *api.ReplicationController) (*api.ReplicationController, error) { - obj, err := c.Fake.Invokes(NewCreateAction("replicationcontrollers", c.Namespace, controller), controller) - if obj == nil { - return nil, err - } - - return obj.(*api.ReplicationController), err -} - -func (c *FakeReplicationControllers) Update(controller *api.ReplicationController) (*api.ReplicationController, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("replicationcontrollers", c.Namespace, controller), controller) - if obj == nil { - return nil, err - } - - return obj.(*api.ReplicationController), err -} - -func (c *FakeReplicationControllers) UpdateStatus(controller *api.ReplicationController) (*api.ReplicationController, error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("replicationcontrollers", "status", c.Namespace, controller), &api.ReplicationController{}) - if obj == nil { - return nil, err - } - return obj.(*api.ReplicationController), err -} - -func (c *FakeReplicationControllers) Delete(name string, options *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("replicationcontrollers", c.Namespace, name), &api.ReplicationController{}) - return err -} - -func (c *FakeReplicationControllers) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("replicationcontrollers", c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_resource_quotas.go b/pkg/client/unversioned/testclient/fake_resource_quotas.go deleted file mode 100644 index 1bb062f4a7bd8..0000000000000 --- a/pkg/client/unversioned/testclient/fake_resource_quotas.go +++ /dev/null @@ -1,83 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeResourceQuotas implements ResourceQuotaInterface. Meant to be embedded into a struct to get a default -// implementation. This makes faking out just the methods you want to test easier. -type FakeResourceQuotas struct { - Fake *Fake - Namespace string -} - -func (c *FakeResourceQuotas) Get(name string) (*api.ResourceQuota, error) { - obj, err := c.Fake.Invokes(NewGetAction("resourcequotas", c.Namespace, name), &api.ResourceQuota{}) - if obj == nil { - return nil, err - } - - return obj.(*api.ResourceQuota), err -} - -func (c *FakeResourceQuotas) List(opts api.ListOptions) (*api.ResourceQuotaList, error) { - obj, err := c.Fake.Invokes(NewListAction("resourcequotas", c.Namespace, opts), &api.ResourceQuotaList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.ResourceQuotaList), err -} - -func (c *FakeResourceQuotas) Create(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error) { - obj, err := c.Fake.Invokes(NewCreateAction("resourcequotas", c.Namespace, resourceQuota), resourceQuota) - if obj == nil { - return nil, err - } - - return obj.(*api.ResourceQuota), err -} - -func (c *FakeResourceQuotas) Update(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("resourcequotas", c.Namespace, resourceQuota), resourceQuota) - if obj == nil { - return nil, err - } - - return obj.(*api.ResourceQuota), err -} - -func (c *FakeResourceQuotas) Delete(name string) error { - _, err := c.Fake.Invokes(NewDeleteAction("resourcequotas", c.Namespace, name), &api.ResourceQuota{}) - return err -} - -func (c *FakeResourceQuotas) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("resourcequotas", c.Namespace, opts)) -} - -func (c *FakeResourceQuotas) UpdateStatus(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("resourcequotas", "status", c.Namespace, resourceQuota), resourceQuota) - if obj == nil { - return nil, err - } - - return obj.(*api.ResourceQuota), err -} diff --git a/pkg/client/unversioned/testclient/fake_rolebindings.go b/pkg/client/unversioned/testclient/fake_rolebindings.go deleted file mode 100644 index d5e6bfc95bfbe..0000000000000 --- a/pkg/client/unversioned/testclient/fake_rolebindings.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/rbac" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeRoleBindings implements RoleBindingInterface -type FakeRoleBindings struct { - Fake *FakeRbac - Namespace string -} - -func (c *FakeRoleBindings) Get(name string) (*rbac.RoleBinding, error) { - obj, err := c.Fake.Invokes(NewGetAction("rolebindings", c.Namespace, name), &rbac.RoleBinding{}) - if obj == nil { - return nil, err - } - - return obj.(*rbac.RoleBinding), err -} - -func (c *FakeRoleBindings) List(opts api.ListOptions) (*rbac.RoleBindingList, error) { - obj, err := c.Fake.Invokes(NewListAction("rolebindings", c.Namespace, opts), &rbac.RoleBindingList{}) - if obj == nil { - return nil, err - } - - return obj.(*rbac.RoleBindingList), err -} - -func (c *FakeRoleBindings) Create(csr *rbac.RoleBinding) (*rbac.RoleBinding, error) { - obj, err := c.Fake.Invokes(NewCreateAction("rolebindings", c.Namespace, csr), csr) - if obj == nil { - return nil, err - } - - return obj.(*rbac.RoleBinding), err -} - -func (c *FakeRoleBindings) Update(csr *rbac.RoleBinding) (*rbac.RoleBinding, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("rolebindings", c.Namespace, csr), csr) - if obj == nil { - return nil, err - } - - return obj.(*rbac.RoleBinding), err -} - -func (c *FakeRoleBindings) Delete(name string, opts *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("rolebindings", c.Namespace, name), &rbac.RoleBinding{}) - return err -} - -func (c *FakeRoleBindings) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("rolebindings", c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_roles.go b/pkg/client/unversioned/testclient/fake_roles.go deleted file mode 100644 index bbbd795c5c9d9..0000000000000 --- a/pkg/client/unversioned/testclient/fake_roles.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/rbac" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeRoles implements RoleInterface -type FakeRoles struct { - Fake *FakeRbac - Namespace string -} - -func (c *FakeRoles) Get(name string) (*rbac.Role, error) { - obj, err := c.Fake.Invokes(NewGetAction("roles", c.Namespace, name), &rbac.Role{}) - if obj == nil { - return nil, err - } - - return obj.(*rbac.Role), err -} - -func (c *FakeRoles) List(opts api.ListOptions) (*rbac.RoleList, error) { - obj, err := c.Fake.Invokes(NewListAction("roles", c.Namespace, opts), &rbac.RoleList{}) - if obj == nil { - return nil, err - } - - return obj.(*rbac.RoleList), err -} - -func (c *FakeRoles) Create(csr *rbac.Role) (*rbac.Role, error) { - obj, err := c.Fake.Invokes(NewCreateAction("roles", c.Namespace, csr), csr) - if obj == nil { - return nil, err - } - - return obj.(*rbac.Role), err -} - -func (c *FakeRoles) Update(csr *rbac.Role) (*rbac.Role, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("roles", c.Namespace, csr), csr) - if obj == nil { - return nil, err - } - - return obj.(*rbac.Role), err -} - -func (c *FakeRoles) Delete(name string, opts *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("roles", c.Namespace, name), &rbac.Role{}) - return err -} - -func (c *FakeRoles) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("roles", c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_scales.go b/pkg/client/unversioned/testclient/fake_scales.go deleted file mode 100644 index 13050eb10facc..0000000000000 --- a/pkg/client/unversioned/testclient/fake_scales.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/apis/extensions" -) - -// FakeScales implements ScaleInterface. Meant to be embedded into a struct to get a default -// implementation. This makes faking out just the methods you want to test easier. -type FakeScales struct { - Fake *FakeExperimental - Namespace string -} - -func (c *FakeScales) Get(kind string, name string) (result *extensions.Scale, err error) { - action := GetActionImpl{} - action.Verb = "get" - action.Namespace = c.Namespace - action.Resource = kind - action.Subresource = "scale" - action.Name = name - obj, err := c.Fake.Invokes(action, &extensions.Scale{}) - result = obj.(*extensions.Scale) - return -} - -func (c *FakeScales) Update(kind string, scale *extensions.Scale) (result *extensions.Scale, err error) { - action := UpdateActionImpl{} - action.Verb = "update" - action.Namespace = c.Namespace - action.Resource = kind - action.Subresource = "scale" - action.Object = scale - obj, err := c.Fake.Invokes(action, scale) - result = obj.(*extensions.Scale) - return -} diff --git a/pkg/client/unversioned/testclient/fake_scheduledjobs.go b/pkg/client/unversioned/testclient/fake_scheduledjobs.go deleted file mode 100644 index 60e866e6a014a..0000000000000 --- a/pkg/client/unversioned/testclient/fake_scheduledjobs.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/batch" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeScheduledJobs implements ScheduledJobInterface. Meant to be embedded into a struct to get a default -// implementation. This makes faking out just the methods you want to test easier. -type FakeScheduledJobs struct { - Fake *FakeBatch - Namespace string -} - -func (c *FakeScheduledJobs) Get(name string) (*batch.ScheduledJob, error) { - obj, err := c.Fake.Invokes(NewGetAction("scheduledjobs", c.Namespace, name), &batch.ScheduledJob{}) - if obj == nil { - return nil, err - } - - return obj.(*batch.ScheduledJob), err -} - -func (c *FakeScheduledJobs) List(opts api.ListOptions) (*batch.ScheduledJobList, error) { - obj, err := c.Fake.Invokes(NewListAction("scheduledjobs", c.Namespace, opts), &batch.ScheduledJobList{}) - if obj == nil { - return nil, err - } - - return obj.(*batch.ScheduledJobList), err -} - -func (c *FakeScheduledJobs) Create(scheduledJob *batch.ScheduledJob) (*batch.ScheduledJob, error) { - obj, err := c.Fake.Invokes(NewCreateAction("scheduledjobs", c.Namespace, scheduledJob), scheduledJob) - if obj == nil { - return nil, err - } - - return obj.(*batch.ScheduledJob), err -} - -func (c *FakeScheduledJobs) Update(scheduledJob *batch.ScheduledJob) (*batch.ScheduledJob, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("scheduledjobs", c.Namespace, scheduledJob), scheduledJob) - if obj == nil { - return nil, err - } - - return obj.(*batch.ScheduledJob), err -} - -func (c *FakeScheduledJobs) Delete(name string, options *api.DeleteOptions) error { - _, err := c.Fake.Invokes(NewDeleteAction("scheduledjobs", c.Namespace, name), &batch.ScheduledJob{}) - return err -} - -func (c *FakeScheduledJobs) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("scheduledjobs", c.Namespace, opts)) -} - -func (c *FakeScheduledJobs) UpdateStatus(scheduledJob *batch.ScheduledJob) (result *batch.ScheduledJob, err error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("scheduledjobs", "status", c.Namespace, scheduledJob), scheduledJob) - if obj == nil { - return nil, err - } - - return obj.(*batch.ScheduledJob), err -} diff --git a/pkg/client/unversioned/testclient/fake_secrets.go b/pkg/client/unversioned/testclient/fake_secrets.go deleted file mode 100644 index 8ead395cb22fc..0000000000000 --- a/pkg/client/unversioned/testclient/fake_secrets.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// Fake implements SecretInterface. 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 FakeSecrets struct { - Fake *Fake - Namespace string -} - -func (c *FakeSecrets) Get(name string) (*api.Secret, error) { - obj, err := c.Fake.Invokes(NewGetAction("secrets", c.Namespace, name), &api.Secret{}) - if obj == nil { - return nil, err - } - - return obj.(*api.Secret), err -} - -func (c *FakeSecrets) List(opts api.ListOptions) (*api.SecretList, error) { - obj, err := c.Fake.Invokes(NewListAction("secrets", c.Namespace, opts), &api.SecretList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.SecretList), err -} - -func (c *FakeSecrets) Create(secret *api.Secret) (*api.Secret, error) { - obj, err := c.Fake.Invokes(NewCreateAction("secrets", c.Namespace, secret), secret) - if obj == nil { - return nil, err - } - - return obj.(*api.Secret), err -} - -func (c *FakeSecrets) Update(secret *api.Secret) (*api.Secret, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("secrets", c.Namespace, secret), secret) - if obj == nil { - return nil, err - } - - return obj.(*api.Secret), err -} - -func (c *FakeSecrets) Delete(name string) error { - _, err := c.Fake.Invokes(NewDeleteAction("secrets", c.Namespace, name), &api.Secret{}) - return err -} - -func (c *FakeSecrets) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("secrets", c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_service_accounts.go b/pkg/client/unversioned/testclient/fake_service_accounts.go deleted file mode 100644 index 43dc3aaf56117..0000000000000 --- a/pkg/client/unversioned/testclient/fake_service_accounts.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeServiceAccounts implements ServiceAccountsInterface. 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 FakeServiceAccounts struct { - Fake *Fake - Namespace string -} - -func (c *FakeServiceAccounts) Get(name string) (*api.ServiceAccount, error) { - obj, err := c.Fake.Invokes(NewGetAction("serviceaccounts", c.Namespace, name), &api.ServiceAccount{}) - if obj == nil { - return nil, err - } - - return obj.(*api.ServiceAccount), err -} - -func (c *FakeServiceAccounts) List(opts api.ListOptions) (*api.ServiceAccountList, error) { - obj, err := c.Fake.Invokes(NewListAction("serviceaccounts", c.Namespace, opts), &api.ServiceAccountList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.ServiceAccountList), err -} - -func (c *FakeServiceAccounts) Create(serviceAccount *api.ServiceAccount) (*api.ServiceAccount, error) { - obj, err := c.Fake.Invokes(NewCreateAction("serviceaccounts", c.Namespace, serviceAccount), serviceAccount) - if obj == nil { - return nil, err - } - - return obj.(*api.ServiceAccount), err -} - -func (c *FakeServiceAccounts) Update(serviceAccount *api.ServiceAccount) (*api.ServiceAccount, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("serviceaccounts", c.Namespace, serviceAccount), serviceAccount) - if obj == nil { - return nil, err - } - - return obj.(*api.ServiceAccount), err -} - -func (c *FakeServiceAccounts) Delete(name string) error { - _, err := c.Fake.Invokes(NewDeleteAction("serviceaccounts", c.Namespace, name), &api.ServiceAccount{}) - return err -} - -func (c *FakeServiceAccounts) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("serviceaccounts", c.Namespace, opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_services.go b/pkg/client/unversioned/testclient/fake_services.go deleted file mode 100644 index 158ad26ce7009..0000000000000 --- a/pkg/client/unversioned/testclient/fake_services.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/client/restclient" - "k8s.io/kubernetes/pkg/watch" -) - -// Fake implements ServiceInterface. 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 FakeServices struct { - Fake *Fake - Namespace string -} - -func (c *FakeServices) Get(name string) (*api.Service, error) { - obj, err := c.Fake.Invokes(NewGetAction("services", c.Namespace, name), &api.Service{}) - if obj == nil { - return nil, err - } - - return obj.(*api.Service), err -} - -func (c *FakeServices) List(opts api.ListOptions) (*api.ServiceList, error) { - obj, err := c.Fake.Invokes(NewListAction("services", c.Namespace, opts), &api.ServiceList{}) - if obj == nil { - return nil, err - } - - return obj.(*api.ServiceList), err -} - -func (c *FakeServices) Create(service *api.Service) (*api.Service, error) { - obj, err := c.Fake.Invokes(NewCreateAction("services", c.Namespace, service), service) - if obj == nil { - return nil, err - } - - return obj.(*api.Service), err -} - -func (c *FakeServices) Update(service *api.Service) (*api.Service, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("services", c.Namespace, service), service) - if obj == nil { - return nil, err - } - - return obj.(*api.Service), err -} - -func (c *FakeServices) UpdateStatus(service *api.Service) (result *api.Service, err error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("services", "status", c.Namespace, service), service) - if obj == nil { - return nil, err - } - - return obj.(*api.Service), err -} - -func (c *FakeServices) Delete(name string) error { - _, err := c.Fake.Invokes(NewDeleteAction("services", c.Namespace, name), &api.Service{}) - return err -} - -func (c *FakeServices) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("services", c.Namespace, opts)) -} - -func (c *FakeServices) ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper { - return c.Fake.InvokesProxy(NewProxyGetAction("services", c.Namespace, scheme, name, port, path, params)) -} diff --git a/pkg/client/unversioned/testclient/fake_storage_classes.go b/pkg/client/unversioned/testclient/fake_storage_classes.go deleted file mode 100644 index ce19dcc276e47..0000000000000 --- a/pkg/client/unversioned/testclient/fake_storage_classes.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/storage" - kclientlib "k8s.io/kubernetes/pkg/client/unversioned" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeStorageClasses implements StorageClassInterface. 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 FakeStorageClasses struct { - Fake *FakeStorage -} - -// Ensure statically that FakeStorageClasses implements StorageClassInterface. -var _ kclientlib.StorageClassInterface = &FakeStorageClasses{} - -func (c *FakeStorageClasses) Get(name string) (*storage.StorageClass, error) { - obj, err := c.Fake.Invokes(NewGetAction("storageclasses", "", name), &storage.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storage.StorageClass), err -} - -func (c *FakeStorageClasses) List(opts api.ListOptions) (*storage.StorageClassList, error) { - obj, err := c.Fake.Invokes(NewListAction("storageclasses", "", opts), &storage.StorageClassList{}) - if obj == nil { - return nil, err - } - return obj.(*storage.StorageClassList), err -} - -func (c *FakeStorageClasses) Create(np *storage.StorageClass) (*storage.StorageClass, error) { - obj, err := c.Fake.Invokes(NewCreateAction("storageclasses", "", np), &storage.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storage.StorageClass), err -} - -func (c *FakeStorageClasses) Update(np *storage.StorageClass) (*storage.StorageClass, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("storageclasses", "", np), &storage.StorageClass{}) - if obj == nil { - return nil, err - } - return obj.(*storage.StorageClass), err -} - -func (c *FakeStorageClasses) Delete(name string) error { - _, err := c.Fake.Invokes(NewDeleteAction("storageclasses", "", name), &storage.StorageClass{}) - return err -} - -func (c *FakeStorageClasses) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("storageclasses", "", opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_subjectaccessreviews.go b/pkg/client/unversioned/testclient/fake_subjectaccessreviews.go deleted file mode 100644 index 54f779dbda24e..0000000000000 --- a/pkg/client/unversioned/testclient/fake_subjectaccessreviews.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/apis/authorization" -) - -// FakeSubjectAccessReviews implements SubjectAccessReviewInterface. Meant to be embedded into a struct to get a default -// implementation. This makes faking out just the methods you want to test easier. -type FakeSubjectAccessReviews struct { - Fake *FakeAuthorization -} - -func (c *FakeSubjectAccessReviews) Create(a *authorization.SubjectAccessReview) (*authorization.SubjectAccessReview, error) { - obj, err := c.Fake.Invokes(NewRootCreateAction("subjectaccessreviews", a), a) - if obj == nil { - return nil, err - } - - return obj.(*authorization.SubjectAccessReview), err -} diff --git a/pkg/client/unversioned/testclient/fake_test.go b/pkg/client/unversioned/testclient/fake_test.go deleted file mode 100644 index 208df0730b555..0000000000000 --- a/pkg/client/unversioned/testclient/fake_test.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -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 testclient - -import ( - "testing" - - client "k8s.io/kubernetes/pkg/client/unversioned" -) - -// This test file just ensures that Fake and structs it is embedded in -// implement Interface. - -func TestFakeImplementsInterface(t *testing.T) { - _ = client.Interface(&Fake{}) -} - -type MyFake struct { - *Fake -} - -func TestEmbeddedFakeImplementsInterface(t *testing.T) { - _ = client.Interface(MyFake{&Fake{}}) - _ = client.Interface(&MyFake{&Fake{}}) -} diff --git a/pkg/client/unversioned/testclient/fake_thirdpartyresources.go b/pkg/client/unversioned/testclient/fake_thirdpartyresources.go deleted file mode 100644 index db5a718504f46..0000000000000 --- a/pkg/client/unversioned/testclient/fake_thirdpartyresources.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - kclientlib "k8s.io/kubernetes/pkg/client/unversioned" - "k8s.io/kubernetes/pkg/watch" -) - -// FakeThirdPartyResources implements ThirdPartyResourceInterface. 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 FakeThirdPartyResources struct { - Fake *FakeExperimental -} - -// Ensure statically that FakeThirdPartyResources implements DaemonInterface. -var _ kclientlib.ThirdPartyResourceInterface = &FakeThirdPartyResources{} - -func (c *FakeThirdPartyResources) Get(name string) (*extensions.ThirdPartyResource, error) { - obj, err := c.Fake.Invokes(NewGetAction("thirdpartyresources", "", name), &extensions.ThirdPartyResource{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.ThirdPartyResource), err -} - -func (c *FakeThirdPartyResources) List(opts api.ListOptions) (*extensions.ThirdPartyResourceList, error) { - obj, err := c.Fake.Invokes(NewListAction("thirdpartyresources", "", opts), &extensions.ThirdPartyResourceList{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.ThirdPartyResourceList), err -} - -func (c *FakeThirdPartyResources) Create(daemon *extensions.ThirdPartyResource) (*extensions.ThirdPartyResource, error) { - obj, err := c.Fake.Invokes(NewCreateAction("thirdpartyresources", "", daemon), &extensions.ThirdPartyResource{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.ThirdPartyResource), err -} - -func (c *FakeThirdPartyResources) Update(daemon *extensions.ThirdPartyResource) (*extensions.ThirdPartyResource, error) { - obj, err := c.Fake.Invokes(NewUpdateAction("thirdpartyresources", "", daemon), &extensions.ThirdPartyResource{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.ThirdPartyResource), err -} - -func (c *FakeThirdPartyResources) UpdateStatus(daemon *extensions.ThirdPartyResource) (*extensions.ThirdPartyResource, error) { - obj, err := c.Fake.Invokes(NewUpdateSubresourceAction("thirdpartyresources", "status", "", daemon), &extensions.ThirdPartyResource{}) - if obj == nil { - return nil, err - } - return obj.(*extensions.ThirdPartyResource), err -} - -func (c *FakeThirdPartyResources) Delete(name string) error { - _, err := c.Fake.Invokes(NewDeleteAction("thirdpartyresources", "", name), &extensions.ThirdPartyResource{}) - return err -} - -func (c *FakeThirdPartyResources) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.Fake.InvokesWatch(NewWatchAction("thirdpartyresources", "", opts)) -} diff --git a/pkg/client/unversioned/testclient/fake_tokenreviews.go b/pkg/client/unversioned/testclient/fake_tokenreviews.go deleted file mode 100644 index c0e6c910412e8..0000000000000 --- a/pkg/client/unversioned/testclient/fake_tokenreviews.go +++ /dev/null @@ -1,35 +0,0 @@ -/* -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 testclient - -import ( - "k8s.io/kubernetes/pkg/apis/authentication" -) - -// FakeTokenReviews implements ClusterRoleInterface -type FakeTokenReviews struct { - Fake *FakeAuthentication -} - -func (c *FakeTokenReviews) Create(review *authentication.TokenReview) (*authentication.TokenReview, error) { - obj, err := c.Fake.Invokes(NewRootCreateAction("tokenreviews", review), review) - if obj == nil { - return nil, err - } - - return obj.(*authentication.TokenReview), err -} diff --git a/pkg/client/unversioned/testclient/fixture.go b/pkg/client/unversioned/testclient/fixture.go deleted file mode 100644 index 6149f0a8deb10..0000000000000 --- a/pkg/client/unversioned/testclient/fixture.go +++ /dev/null @@ -1,313 +0,0 @@ -/* -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 testclient - -import ( - "fmt" - "io/ioutil" - "reflect" - "strings" - - "k8s.io/kubernetes/pkg/api/errors" - "k8s.io/kubernetes/pkg/api/meta" - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/client/restclient" - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util/yaml" - "k8s.io/kubernetes/pkg/watch" -) - -// ObjectRetriever abstracts the implementation for retrieving or setting generic -// objects. It is intended to be used to fake calls to a server by returning -// objects based on their kind and name. -type ObjectRetriever interface { - // Kind should return a resource or a list of resources (depending on the provided kind and - // name). It should return an error if the caller should communicate an error to the server. - Kind(gvk unversioned.GroupVersionKind, name string) (runtime.Object, error) - // Add adds a runtime object for test purposes into this object. - Add(runtime.Object) error -} - -// ObjectScheme abstracts the implementation of common operations on objects. -type ObjectScheme interface { - runtime.ObjectCreater - runtime.ObjectCopier - runtime.ObjectTyper -} - -// ObjectReaction returns a ReactionFunc that takes a generic action string of the form -// - or -- and attempts to return a runtime -// Object or error that matches the requested action. For instance, list-replicationControllers -// should attempt to return a list of replication controllers. This method delegates to the -// ObjectRetriever interface to satisfy retrieval of lists or retrieval of single items. -// TODO: add support for sub resources -func ObjectReaction(o ObjectRetriever, mapper meta.RESTMapper) ReactionFunc { - - return func(action Action) (bool, runtime.Object, error) { - kind, err := mapper.KindFor(unversioned.GroupVersionResource{Resource: action.GetResource()}) - if err != nil { - return false, nil, fmt.Errorf("unrecognized action %s: %v", action.GetResource(), err) - } - - // TODO: have mapper return a Kind for a subresource? - switch castAction := action.(type) { - case ListAction: - kind.Kind += "List" - resource, err := o.Kind(kind, "") - return true, resource, err - - case GetAction: - resource, err := o.Kind(kind, castAction.GetName()) - return true, resource, err - - case DeleteAction: - resource, err := o.Kind(kind, castAction.GetName()) - return true, resource, err - - case CreateAction: - accessor, err := meta.Accessor(castAction.GetObject()) - if err != nil { - return true, nil, err - } - resource, err := o.Kind(kind, accessor.GetName()) - return true, resource, err - - case UpdateAction: - accessor, err := meta.Accessor(castAction.GetObject()) - if err != nil { - return true, nil, err - } - resource, err := o.Kind(kind, accessor.GetName()) - return true, resource, err - - default: - return false, nil, fmt.Errorf("no reaction implemented for %s", action) - } - } -} - -// AddObjectsFromPath loads the JSON or YAML file containing Kubernetes API resources -// and adds them to the provided ObjectRetriever. -func AddObjectsFromPath(path string, o ObjectRetriever, decoder runtime.Decoder) error { - data, err := ioutil.ReadFile(path) - if err != nil { - return err - } - data, err = yaml.ToJSON(data) - if err != nil { - return err - } - obj, err := runtime.Decode(decoder, data) - if err != nil { - return err - } - if err := o.Add(obj); err != nil { - return err - } - return nil -} - -type objects struct { - types map[string][]runtime.Object - last map[string]int - scheme ObjectScheme - decoder runtime.Decoder -} - -var _ ObjectRetriever = &objects{} - -// NewObjects implements the ObjectRetriever interface by introspecting the -// objects provided to Add() and returning them when the Kind method is invoked. -// If an api.List object is provided to Add(), each child item is added. If an -// object is added that is itself a list (PodList, ServiceList) then that is added -// to the "PodList" kind. If no PodList is added, the retriever will take any loaded -// Pods and return them in a list. If an api.Status is added, and the Details.Kind field -// is set, that status will be returned instead (as an error if Status != Success, or -// as a runtime.Object if Status == Success). If multiple PodLists are provided, they -// will be returned in order by the Kind call, and the last PodList will be reused for -// subsequent calls. -func NewObjects(scheme ObjectScheme, decoder runtime.Decoder) ObjectRetriever { - return objects{ - types: make(map[string][]runtime.Object), - last: make(map[string]int), - scheme: scheme, - decoder: decoder, - } -} - -func (o objects) Kind(kind unversioned.GroupVersionKind, name string) (runtime.Object, error) { - kind.Version = runtime.APIVersionInternal - - empty, _ := o.scheme.New(kind) - nilValue := reflect.Zero(reflect.TypeOf(empty)).Interface().(runtime.Object) - - arr, ok := o.types[kind.Kind] - if !ok { - if strings.HasSuffix(kind.Kind, "List") { - itemKind := kind.Kind[:len(kind.Kind)-4] - arr, ok := o.types[itemKind] - if !ok { - return empty, nil - } - out, err := o.scheme.New(kind) - if err != nil { - return nilValue, err - } - if err := meta.SetList(out, arr); err != nil { - return nilValue, err - } - if out, err = o.scheme.Copy(out); err != nil { - return nilValue, err - } - return out, nil - } - return nilValue, errors.NewNotFound(unversioned.GroupResource{Group: kind.Group, Resource: kind.Kind}, name) - } - - index := o.last[kind.Kind] - if index >= len(arr) { - index = len(arr) - 1 - } - if index < 0 { - return nilValue, errors.NewNotFound(unversioned.GroupResource{Group: kind.Group, Resource: kind.Kind}, name) - } - out, err := o.scheme.Copy(arr[index]) - if err != nil { - return nilValue, err - } - o.last[kind.Kind] = index + 1 - - if status, ok := out.(*unversioned.Status); ok { - if status.Details != nil { - status.Details.Kind = kind.Kind - } - if status.Status != unversioned.StatusSuccess { - return nilValue, &errors.StatusError{ErrStatus: *status} - } - } - - return out, nil -} - -func (o objects) Add(obj runtime.Object) error { - gvks, _, err := o.scheme.ObjectKinds(obj) - if err != nil { - return err - } - kind := gvks[0].Kind - - switch { - case meta.IsListType(obj): - if kind != "List" { - o.types[kind] = append(o.types[kind], obj) - } - - list, err := meta.ExtractList(obj) - if err != nil { - return err - } - if errs := runtime.DecodeList(list, o.decoder); len(errs) > 0 { - return errs[0] - } - for _, obj := range list { - if err := o.Add(obj); err != nil { - return err - } - } - default: - if status, ok := obj.(*unversioned.Status); ok && status.Details != nil { - kind = status.Details.Kind - } - o.types[kind] = append(o.types[kind], obj) - } - - 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() - 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() - 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() - if !resourceCovers { - return false - } - - return true -} - -func (r *SimpleProxyReactor) React(action Action) (bool, restclient.ResponseWrapper, error) { - return r.Reaction(action) -} diff --git a/pkg/client/unversioned/testclient/simple/simple_testclient.go b/pkg/client/unversioned/testclient/simple/simple_testclient.go index 314beb5ef965e..ad0371846e92c 100644 --- a/pkg/client/unversioned/testclient/simple/simple_testclient.go +++ b/pkg/client/unversioned/testclient/simple/simple_testclient.go @@ -30,7 +30,6 @@ import ( "k8s.io/kubernetes/pkg/apimachinery/registered" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" "k8s.io/kubernetes/pkg/client/restclient" - client "k8s.io/kubernetes/pkg/client/unversioned" "k8s.io/kubernetes/pkg/fields" "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/runtime" @@ -55,7 +54,6 @@ type Response struct { } type Client struct { - *client.Client Clientset *clientset.Clientset Request Request Response Response @@ -82,35 +80,7 @@ func (c *Client) Setup(t *testing.T) *Client { c.handler.ResponseBody = *responseBody } c.server = httptest.NewServer(c.handler) - if c.Client == nil { - c.Client = client.NewOrDie(&restclient.Config{ - Host: c.server.URL, - ContentConfig: restclient.ContentConfig{GroupVersion: ®istered.GroupOrDie(api.GroupName).GroupVersion}, - }) - - // TODO: caesarxuchao: hacky way to specify version of Experimental client. - // We will fix this by supporting multiple group versions in Config - c.AutoscalingClient = client.NewAutoscalingOrDie(&restclient.Config{ - Host: c.server.URL, - ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Autoscaling.GroupVersion()}, - }) - c.BatchClient = client.NewBatchOrDie(&restclient.Config{ - Host: c.server.URL, - ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Batch.GroupVersion()}, - }) - c.ExtensionsClient = client.NewExtensionsOrDie(&restclient.Config{ - Host: c.server.URL, - ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Extensions.GroupVersion()}, - }) - c.RbacClient = client.NewRbacOrDie(&restclient.Config{ - Host: c.server.URL, - ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Rbac.GroupVersion()}, - }) - c.StorageClient = client.NewStorageOrDie(&restclient.Config{ - Host: c.server.URL, - ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Storage.GroupVersion()}, - }) - + if c.Clientset == nil { c.Clientset = clientset.NewForConfigOrDie(&restclient.Config{Host: c.server.URL}) } c.QueryValidator = map[string]func(string, string) bool{} diff --git a/pkg/client/unversioned/testclient/testclient.go b/pkg/client/unversioned/testclient/testclient.go deleted file mode 100644 index fb3195ebc3bcf..0000000000000 --- a/pkg/client/unversioned/testclient/testclient.go +++ /dev/null @@ -1,533 +0,0 @@ -/* -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 testclient - -import ( - "fmt" - "sync" - - "github.com/emicklei/go-restful/swagger" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/api/v1" - "k8s.io/kubernetes/pkg/apimachinery/registered" - "k8s.io/kubernetes/pkg/client/restclient" - "k8s.io/kubernetes/pkg/client/typed/discovery" - client "k8s.io/kubernetes/pkg/client/unversioned" - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/version" - "k8s.io/kubernetes/pkg/watch" -) - -// NewSimpleFake returns a client that will respond with the provided objects -func NewSimpleFake(objects ...runtime.Object) *Fake { - o := NewObjects(api.Scheme, api.Codecs.UniversalDecoder()) - for _, obj := range objects { - if err := o.Add(obj); err != nil { - panic(err) - } - } - - fakeClient := &Fake{} - fakeClient.AddReactor("*", "*", ObjectReaction(o, registered.RESTMapper())) - - fakeClient.AddWatchReactor("*", DefaultWatchReactor(watch.NewFake(), nil)) - - return fakeClient -} - -// 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 indicated 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 indicated handled=false - React(action Action) (handled bool, ret restclient.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 continue ignore the results and continue to the next ReactionFunc -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 continue 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 continue ignore the results and continue to the next ProxyReactionFunc -type ProxyReactionFunc func(action Action) (handled bool, ret restclient.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 ReactFn (if provided). -// 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 ReactFn (if provided). -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 ReactFn (if provided). -func (c *Fake) InvokesProxy(action Action) restclient.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 -} - -func (c *Fake) LimitRanges(namespace string) client.LimitRangeInterface { - return &FakeLimitRanges{Fake: c, Namespace: namespace} -} - -func (c *Fake) ResourceQuotas(namespace string) client.ResourceQuotaInterface { - return &FakeResourceQuotas{Fake: c, Namespace: namespace} -} - -func (c *Fake) ReplicationControllers(namespace string) client.ReplicationControllerInterface { - return &FakeReplicationControllers{Fake: c, Namespace: namespace} -} - -func (c *Fake) Nodes() client.NodeInterface { - return &FakeNodes{Fake: c} -} - -func (c *Fake) PodSecurityPolicies() client.PodSecurityPolicyInterface { - return &FakePodSecurityPolicy{Fake: c} -} - -func (c *Fake) Events(namespace string) client.EventInterface { - return &FakeEvents{Fake: c, Namespace: namespace} -} - -func (c *Fake) Endpoints(namespace string) client.EndpointsInterface { - return &FakeEndpoints{Fake: c, Namespace: namespace} -} - -func (c *Fake) PersistentVolumes() client.PersistentVolumeInterface { - return &FakePersistentVolumes{Fake: c} -} - -func (c *Fake) PersistentVolumeClaims(namespace string) client.PersistentVolumeClaimInterface { - return &FakePersistentVolumeClaims{Fake: c, Namespace: namespace} -} - -func (c *Fake) Pods(namespace string) client.PodInterface { - return &FakePods{Fake: c, Namespace: namespace} -} - -func (c *Fake) PodTemplates(namespace string) client.PodTemplateInterface { - return &FakePodTemplates{Fake: c, Namespace: namespace} -} - -func (c *Fake) Services(namespace string) client.ServiceInterface { - return &FakeServices{Fake: c, Namespace: namespace} -} - -func (c *Fake) ServiceAccounts(namespace string) client.ServiceAccountsInterface { - return &FakeServiceAccounts{Fake: c, Namespace: namespace} -} - -func (c *Fake) Secrets(namespace string) client.SecretsInterface { - return &FakeSecrets{Fake: c, Namespace: namespace} -} - -func (c *Fake) Namespaces() client.NamespaceInterface { - return &FakeNamespaces{Fake: c} -} - -func (c *Fake) Apps() client.AppsInterface { - return &FakeApps{c} -} - -func (c *Fake) Authorization() client.AuthorizationInterface { - return &FakeAuthorization{c} -} - -func (c *Fake) Autoscaling() client.AutoscalingInterface { - return &FakeAutoscaling{c} -} - -func (c *Fake) Batch() client.BatchInterface { - return &FakeBatch{c} -} - -func (c *Fake) Certificates() client.CertificatesInterface { - return &FakeCertificates{c} -} - -func (c *Fake) Extensions() client.ExtensionsInterface { - return &FakeExperimental{c} -} - -func (c *Fake) Discovery() discovery.DiscoveryInterface { - return &FakeDiscovery{c} -} - -func (c *Fake) ComponentStatuses() client.ComponentStatusInterface { - return &FakeComponentStatuses{Fake: c} -} - -func (c *Fake) ConfigMaps(namespace string) client.ConfigMapsInterface { - return &FakeConfigMaps{Fake: c, Namespace: namespace} -} - -func (c *Fake) Rbac() client.RbacInterface { - return &FakeRbac{Fake: c} -} - -func (c *Fake) Storage() client.StorageInterface { - return &FakeStorage{Fake: c} -} - -func (c *Fake) Authentication() client.AuthenticationInterface { - return &FakeAuthentication{Fake: c} -} - -// SwaggerSchema returns an empty swagger.ApiDeclaration for testing -func (c *Fake) SwaggerSchema(version unversioned.GroupVersion) (*swagger.ApiDeclaration, error) { - action := ActionImpl{} - action.Verb = "get" - if version == v1.SchemeGroupVersion { - action.Resource = "/swaggerapi/api/" + version.Version - } else { - action.Resource = "/swaggerapi/apis/" + version.Group + "/" + version.Version - } - - c.Invokes(action, nil) - return &swagger.ApiDeclaration{}, nil -} - -// NewSimpleFakeApps returns a client that will respond with the provided objects -func NewSimpleFakeApps(objects ...runtime.Object) *FakeApps { - return &FakeApps{Fake: NewSimpleFake(objects...)} -} - -type FakeApps struct { - *Fake -} - -func (c *FakeApps) PetSets(namespace string) client.PetSetInterface { - return &FakePetSets{Fake: c, Namespace: namespace} -} - -// NewSimpleFakeAuthorization returns a client that will respond with the provided objects -func NewSimpleFakeAuthorization(objects ...runtime.Object) *FakeAuthorization { - return &FakeAuthorization{Fake: NewSimpleFake(objects...)} -} - -type FakeAuthorization struct { - *Fake -} - -func (c *FakeAuthorization) SubjectAccessReviews() client.SubjectAccessReviewInterface { - return &FakeSubjectAccessReviews{Fake: c} -} - -// NewSimpleFakeAutoscaling returns a client that will respond with the provided objects -func NewSimpleFakeAutoscaling(objects ...runtime.Object) *FakeAutoscaling { - return &FakeAutoscaling{Fake: NewSimpleFake(objects...)} -} - -type FakeAutoscaling struct { - *Fake -} - -func (c *FakeAutoscaling) HorizontalPodAutoscalers(namespace string) client.HorizontalPodAutoscalerInterface { - return &FakeHorizontalPodAutoscalers{Fake: c, Namespace: namespace} -} - -func NewSimpleFakeAuthentication(objects ...runtime.Object) *FakeAuthentication { - return &FakeAuthentication{Fake: NewSimpleFake(objects...)} -} - -type FakeAuthentication struct { - *Fake -} - -func (c *FakeAuthentication) TokenReviews() client.TokenReviewInterface { - return &FakeTokenReviews{Fake: c} -} - -// NewSimpleFakeBatch returns a client that will respond with the provided objects -func NewSimpleFakeBatch(objects ...runtime.Object) *FakeBatch { - return &FakeBatch{Fake: NewSimpleFake(objects...)} -} - -type FakeBatch struct { - *Fake -} - -func (c *FakeBatch) Jobs(namespace string) client.JobInterface { - return &FakeJobsV1{Fake: c, Namespace: namespace} -} - -func (c *FakeBatch) ScheduledJobs(namespace string) client.ScheduledJobInterface { - return &FakeScheduledJobs{Fake: c, Namespace: namespace} -} - -// NewSimpleFakeExp returns a client that will respond with the provided objects -func NewSimpleFakeExp(objects ...runtime.Object) *FakeExperimental { - return &FakeExperimental{Fake: NewSimpleFake(objects...)} -} - -type FakeExperimental struct { - *Fake -} - -func (c *FakeExperimental) DaemonSets(namespace string) client.DaemonSetInterface { - return &FakeDaemonSets{Fake: c, Namespace: namespace} -} - -func (c *FakeExperimental) Deployments(namespace string) client.DeploymentInterface { - return &FakeDeployments{Fake: c, Namespace: namespace} -} - -func (c *FakeExperimental) Scales(namespace string) client.ScaleInterface { - return &FakeScales{Fake: c, Namespace: namespace} -} - -func (c *FakeExperimental) Jobs(namespace string) client.JobInterface { - return &FakeJobs{Fake: c, Namespace: namespace} -} - -func (c *FakeExperimental) Ingress(namespace string) client.IngressInterface { - return &FakeIngress{Fake: c, Namespace: namespace} -} - -func (c *FakeExperimental) ThirdPartyResources() client.ThirdPartyResourceInterface { - return &FakeThirdPartyResources{Fake: c} -} - -func (c *FakeExperimental) ReplicaSets(namespace string) client.ReplicaSetInterface { - return &FakeReplicaSets{Fake: c, Namespace: namespace} -} - -func (c *FakeExperimental) NetworkPolicies(namespace string) client.NetworkPolicyInterface { - return &FakeNetworkPolicies{Fake: c, Namespace: namespace} -} - -func NewSimpleFakeRbac(objects ...runtime.Object) *FakeRbac { - return &FakeRbac{Fake: NewSimpleFake(objects...)} -} - -type FakeRbac struct { - *Fake -} - -func (c *FakeRbac) Roles(namespace string) client.RoleInterface { - return &FakeRoles{Fake: c, Namespace: namespace} -} - -func (c *FakeRbac) RoleBindings(namespace string) client.RoleBindingInterface { - return &FakeRoleBindings{Fake: c, Namespace: namespace} -} - -func (c *FakeRbac) ClusterRoles() client.ClusterRoleInterface { - return &FakeClusterRoles{Fake: c} -} - -func (c *FakeRbac) ClusterRoleBindings() client.ClusterRoleBindingInterface { - return &FakeClusterRoleBindings{Fake: c} -} - -func NewSimpleFakeStorage(objects ...runtime.Object) *FakeStorage { - return &FakeStorage{Fake: NewSimpleFake(objects...)} -} - -type FakeStorage struct { - *Fake -} - -func (c *FakeStorage) StorageClasses() client.StorageClassInterface { - return &FakeStorageClasses{Fake: c} -} - -type FakeDiscovery struct { - *Fake -} - -func (c *FakeDiscovery) ServerPreferredResources() ([]unversioned.GroupVersionResource, error) { - return nil, nil -} - -func (c *FakeDiscovery) ServerPreferredNamespacedResources() ([]unversioned.GroupVersionResource, error) { - return nil, nil -} - -func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*unversioned.APIResourceList, error) { - action := ActionImpl{ - Verb: "get", - 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: "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 = "version" - - c.Invokes(action, nil) - versionInfo := version.Get() - return &versionInfo, nil -} - -func (c *FakeDiscovery) RESTClient() restclient.Interface { - return nil -} diff --git a/pkg/client/unversioned/testclient/testclient_test.go b/pkg/client/unversioned/testclient/testclient_test.go deleted file mode 100644 index d10c1845a93e1..0000000000000 --- a/pkg/client/unversioned/testclient/testclient_test.go +++ /dev/null @@ -1,75 +0,0 @@ -/* -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 testclient - -import ( - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/errors" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/runtime" -) - -func TestNewClient(t *testing.T) { - o := NewObjects(api.Scheme, api.Codecs.UniversalDecoder()) - if err := AddObjectsFromPath("../../../../examples/guestbook/frontend-service.yaml", o, api.Codecs.UniversalDecoder()); err != nil { - t.Fatal(err) - } - client := &Fake{} - client.AddReactor("*", "*", ObjectReaction(o, testapi.Default.RESTMapper())) - list, err := client.Services("test").List(api.ListOptions{}) - if err != nil { - t.Fatal(err) - } - if len(list.Items) != 1 { - t.Fatalf("unexpected list %#v", list) - } - - // When list is invoked a second time, the same results are returned. - list, err = client.Services("test").List(api.ListOptions{}) - if err != nil { - t.Fatal(err) - } - if len(list.Items) != 1 { - t.Fatalf("unexpected list %#v", list) - } - t.Logf("list: %#v", list) -} - -func TestErrors(t *testing.T) { - o := NewObjects(api.Scheme, api.Codecs.UniversalDecoder()) - o.Add(&api.List{ - Items: []runtime.Object{ - // This first call to List will return this error - &(errors.NewNotFound(api.Resource("ServiceList"), "").ErrStatus), - // The second call to List will return this error - &(errors.NewForbidden(api.Resource("ServiceList"), "", nil).ErrStatus), - }, - }) - client := &Fake{} - client.AddReactor("*", "*", ObjectReaction(o, testapi.Default.RESTMapper())) - _, err := client.Services("test").List(api.ListOptions{}) - if !errors.IsNotFound(err) { - t.Fatalf("unexpected error: %v", err) - } - t.Logf("error: %#v", err.(*errors.StatusError).Status()) - _, err = client.Services("test").List(api.ListOptions{}) - if !errors.IsForbidden(err) { - t.Fatalf("unexpected error: %v", err) - } -} diff --git a/pkg/client/unversioned/thirdpartyresources.go b/pkg/client/unversioned/thirdpartyresources.go deleted file mode 100644 index 68adddbe7c19a..0000000000000 --- a/pkg/client/unversioned/thirdpartyresources.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/watch" -) - -// ThirdPartyResourceNamespacer has methods to work with ThirdPartyResource resources in a namespace -type ThirdPartyResourceNamespacer interface { - ThirdPartyResources() ThirdPartyResourceInterface -} - -type ThirdPartyResourceInterface interface { - List(opts api.ListOptions) (*extensions.ThirdPartyResourceList, error) - Get(name string) (*extensions.ThirdPartyResource, error) - Create(ctrl *extensions.ThirdPartyResource) (*extensions.ThirdPartyResource, error) - Update(ctrl *extensions.ThirdPartyResource) (*extensions.ThirdPartyResource, error) - UpdateStatus(ctrl *extensions.ThirdPartyResource) (*extensions.ThirdPartyResource, error) - Delete(name string) error - Watch(opts api.ListOptions) (watch.Interface, error) -} - -// thirdPartyResources implements DaemonsSetsNamespacer interface -type thirdPartyResources struct { - r *ExtensionsClient -} - -func newThirdPartyResources(c *ExtensionsClient) *thirdPartyResources { - return &thirdPartyResources{c} -} - -// Ensure statically that thirdPartyResources implements ThirdPartyResourcesInterface. -var _ ThirdPartyResourceInterface = &thirdPartyResources{} - -func (c *thirdPartyResources) List(opts api.ListOptions) (result *extensions.ThirdPartyResourceList, err error) { - result = &extensions.ThirdPartyResourceList{} - err = c.r.Get().Resource("thirdpartyresources").VersionedParams(&opts, api.ParameterCodec).Do().Into(result) - return -} - -// Get returns information about a particular third party resource. -func (c *thirdPartyResources) Get(name string) (result *extensions.ThirdPartyResource, err error) { - result = &extensions.ThirdPartyResource{} - err = c.r.Get().Resource("thirdpartyresources").Name(name).Do().Into(result) - return -} - -// Create creates a new third party resource. -func (c *thirdPartyResources) Create(resource *extensions.ThirdPartyResource) (result *extensions.ThirdPartyResource, err error) { - result = &extensions.ThirdPartyResource{} - err = c.r.Post().Resource("thirdpartyresources").Body(resource).Do().Into(result) - return -} - -// Update updates an existing third party resource. -func (c *thirdPartyResources) Update(resource *extensions.ThirdPartyResource) (result *extensions.ThirdPartyResource, err error) { - result = &extensions.ThirdPartyResource{} - err = c.r.Put().Resource("thirdpartyresources").Name(resource.Name).Body(resource).Do().Into(result) - return -} - -// UpdateStatus updates an existing third party resource status -func (c *thirdPartyResources) UpdateStatus(resource *extensions.ThirdPartyResource) (result *extensions.ThirdPartyResource, err error) { - result = &extensions.ThirdPartyResource{} - err = c.r.Put().Resource("thirdpartyresources").Name(resource.Name).SubResource("status").Body(resource).Do().Into(result) - return -} - -// Delete deletes an existing third party resource. -func (c *thirdPartyResources) Delete(name string) error { - return c.r.Delete().Resource("thirdpartyresources").Name(name).Do().Error() -} - -// Watch returns a watch.Interface that watches the requested third party resources. -func (c *thirdPartyResources) Watch(opts api.ListOptions) (watch.Interface, error) { - return c.r.Get(). - Prefix("watch"). - Resource("thirdpartyresources"). - VersionedParams(&opts, api.ParameterCodec). - Watch() -} diff --git a/pkg/client/unversioned/thirdpartyresources_test.go b/pkg/client/unversioned/thirdpartyresources_test.go deleted file mode 100644 index c5ab51069aa3a..0000000000000 --- a/pkg/client/unversioned/thirdpartyresources_test.go +++ /dev/null @@ -1,177 +0,0 @@ -/* -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 unversioned_test - -import ( - "testing" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/testapi" - "k8s.io/kubernetes/pkg/apis/extensions" - "k8s.io/kubernetes/pkg/client/unversioned/testclient/simple" -) - -func getThirdPartyResourceName() string { - return "thirdpartyresources" -} - -func TestListThirdPartyResources(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{ - Method: "GET", - Path: testapi.Extensions.ResourcePath(getThirdPartyResourceName(), "", ""), - }, - Response: simple.Response{StatusCode: 200, - Body: &extensions.ThirdPartyResourceList{ - Items: []extensions.ThirdPartyResource{ - { - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Description: "test third party resource", - }, - }, - }, - }, - } - receivedDSs, err := c.Setup(t).Extensions().ThirdPartyResources().List(api.ListOptions{}) - defer c.Close() - c.Validate(t, receivedDSs, err) - -} - -func TestGetThirdPartyResource(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{Method: "GET", Path: testapi.Extensions.ResourcePath(getThirdPartyResourceName(), "", "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.ThirdPartyResource{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Description: "test third party resource", - }, - }, - } - receivedThirdPartyResource, err := c.Setup(t).Extensions().ThirdPartyResources().Get("foo") - defer c.Close() - c.Validate(t, receivedThirdPartyResource, err) -} - -func TestGetThirdPartyResourceWithNoName(t *testing.T) { - c := &simple.Client{Error: true} - receivedPod, err := c.Setup(t).Extensions().ThirdPartyResources().Get("") - defer c.Close() - if (err != nil) && (err.Error() != simple.NameRequiredError) { - t.Errorf("Expected error: %v, but got %v", simple.NameRequiredError, err) - } - - c.Validate(t, receivedPod, err) -} - -func TestUpdateThirdPartyResource(t *testing.T) { - requestThirdPartyResource := &extensions.ThirdPartyResource{ - ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Extensions.ResourcePath(getThirdPartyResourceName(), "", "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.ThirdPartyResource{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Description: "test third party resource", - }, - }, - } - receivedThirdPartyResource, err := c.Setup(t).Extensions().ThirdPartyResources().Update(requestThirdPartyResource) - defer c.Close() - c.Validate(t, receivedThirdPartyResource, err) -} - -func TestUpdateThirdPartyResourceUpdateStatus(t *testing.T) { - requestThirdPartyResource := &extensions.ThirdPartyResource{ - ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "PUT", Path: testapi.Extensions.ResourcePath(getThirdPartyResourceName(), "", "foo") + "/status", Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.ThirdPartyResource{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Description: "test third party resource", - }, - }, - } - receivedThirdPartyResource, err := c.Setup(t).Extensions().ThirdPartyResources().UpdateStatus(requestThirdPartyResource) - defer c.Close() - c.Validate(t, receivedThirdPartyResource, err) -} - -func TestDeleteThirdPartyResource(t *testing.T) { - c := &simple.Client{ - Request: simple.Request{Method: "DELETE", Path: testapi.Extensions.ResourcePath(getThirdPartyResourceName(), "", "foo"), Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{StatusCode: 200}, - } - err := c.Setup(t).Extensions().ThirdPartyResources().Delete("foo") - defer c.Close() - c.Validate(t, nil, err) -} - -func TestCreateThirdPartyResource(t *testing.T) { - requestThirdPartyResource := &extensions.ThirdPartyResource{ - ObjectMeta: api.ObjectMeta{Name: "foo"}, - } - c := &simple.Client{ - Request: simple.Request{Method: "POST", Path: testapi.Extensions.ResourcePath(getThirdPartyResourceName(), "", ""), Body: requestThirdPartyResource, Query: simple.BuildQueryValues(nil)}, - Response: simple.Response{ - StatusCode: 200, - Body: &extensions.ThirdPartyResource{ - ObjectMeta: api.ObjectMeta{ - Name: "foo", - Labels: map[string]string{ - "foo": "bar", - "name": "baz", - }, - }, - Description: "test third party resource", - }, - }, - } - receivedThirdPartyResource, err := c.Setup(t).Extensions().ThirdPartyResources().Create(requestThirdPartyResource) - defer c.Close() - c.Validate(t, receivedThirdPartyResource, err) -} diff --git a/pkg/client/unversioned/tokenreviews.go b/pkg/client/unversioned/tokenreviews.go deleted file mode 100644 index 91c6bb60034a4..0000000000000 --- a/pkg/client/unversioned/tokenreviews.go +++ /dev/null @@ -1,49 +0,0 @@ -/* -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 unversioned - -import ( - "k8s.io/kubernetes/pkg/apis/authentication" -) - -// TokenReviews has methods to work with TokenReview resources in a namespace -type TokenReviewsInterface interface { - TokenReviews() TokenReviewInterface -} - -// TokenReviewInterface has methods to work with TokenReview resources. -type TokenReviewInterface interface { - Create(tokenReview *authentication.TokenReview) (*authentication.TokenReview, error) -} - -// tokenReviews implements TokenReviewsNamespacer interface -type tokenReviews struct { - client *AuthenticationClient -} - -// newTokenReviews returns a tokenReviews -func newTokenReviews(c *AuthenticationClient) *tokenReviews { - return &tokenReviews{ - client: c, - } -} - -func (c *tokenReviews) Create(obj *authentication.TokenReview) (result *authentication.TokenReview, err error) { - result = &authentication.TokenReview{} - err = c.client.Post().Resource("tokenreviews").Body(obj).Do().Into(result) - return -}