Zack Williams | e940c7a | 2019-08-21 14:25:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2016 The Kubernetes Authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package v1 |
| 18 | |
| 19 | import ( |
| 20 | "k8s.io/api/core/v1" |
| 21 | policy "k8s.io/api/policy/v1beta1" |
| 22 | "k8s.io/client-go/kubernetes/scheme" |
| 23 | restclient "k8s.io/client-go/rest" |
| 24 | ) |
| 25 | |
| 26 | // The PodExpansion interface allows manually adding extra methods to the PodInterface. |
| 27 | type PodExpansion interface { |
| 28 | Bind(binding *v1.Binding) error |
| 29 | Evict(eviction *policy.Eviction) error |
| 30 | GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request |
| 31 | } |
| 32 | |
| 33 | // Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored). |
| 34 | func (c *pods) Bind(binding *v1.Binding) error { |
| 35 | return c.client.Post().Namespace(c.ns).Resource("pods").Name(binding.Name).SubResource("binding").Body(binding).Do().Error() |
| 36 | } |
| 37 | |
| 38 | func (c *pods) Evict(eviction *policy.Eviction) error { |
| 39 | return c.client.Post().Namespace(c.ns).Resource("pods").Name(eviction.Name).SubResource("eviction").Body(eviction).Do().Error() |
| 40 | } |
| 41 | |
| 42 | // Get constructs a request for getting the logs for a pod |
| 43 | func (c *pods) GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request { |
| 44 | return c.client.Get().Namespace(c.ns).Name(name).Resource("pods").SubResource("log").VersionedParams(opts, scheme.ParameterCodec) |
| 45 | } |