blob: ed876be8b5a8d0753e1d95b419082f075470fbe3 [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001/*
2Copyright 2016 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package v1
18
19import (
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.
27type 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).
34func (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
38func (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
43func (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}