mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-03 18:26:59 +00:00
client-go: add ProxyGet expansion method for pods
Currently, the proxy subresource is not supported for pods in client-go.
Today, invoking this requires using the REST client directly.
To make using the proxy resource easier, this commit adds a ProxyGet
method for pods in pod_expansion.go similar to the ProxyGet method
for services in service_expansion.go.
Ref: d8febccacf/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/service_expansion.go
Kubernetes-commit: 72ab11193a419f0e0e66e86c4e6be9991c3682f2
This commit is contained in:
parent
58357f96bf
commit
8c1e3c3fbd
@ -89,3 +89,7 @@ func (c *FakePods) Evict(ctx context.Context, eviction *policy.Eviction) error {
|
||||
_, err := c.Fake.Invokes(action, eviction)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *FakePods) ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper {
|
||||
return c.Fake.InvokesProxy(core.NewProxyGetAction(podsResource, c.ns, scheme, name, port, path, params))
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
policy "k8s.io/api/policy/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/net"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
)
|
||||
@ -31,6 +32,7 @@ type PodExpansion interface {
|
||||
Bind(ctx context.Context, binding *v1.Binding, opts metav1.CreateOptions) error
|
||||
Evict(ctx context.Context, eviction *policy.Eviction) error
|
||||
GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request
|
||||
ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper
|
||||
}
|
||||
|
||||
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored).
|
||||
@ -46,3 +48,17 @@ func (c *pods) Evict(ctx context.Context, eviction *policy.Eviction) error {
|
||||
func (c *pods) GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request {
|
||||
return c.client.Get().Namespace(c.ns).Name(name).Resource("pods").SubResource("log").VersionedParams(opts, scheme.ParameterCodec)
|
||||
}
|
||||
|
||||
// ProxyGet returns a response of the pod by calling it through the proxy.
|
||||
func (c *pods) ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper {
|
||||
request := c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("pods").
|
||||
SubResource("proxy").
|
||||
Name(net.JoinSchemeNamePort(scheme, name, port)).
|
||||
Suffix(path)
|
||||
for k, v := range params {
|
||||
request = request.Param(k, v)
|
||||
}
|
||||
return request
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user