mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Merge pull request #16926 from liggitt/metrics_https
Auto commit by PR queue bot
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/fields"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/watch"
|
||||
)
|
||||
|
||||
@@ -36,7 +37,7 @@ type ServiceInterface interface {
|
||||
Update(srv *api.Service) (*api.Service, error)
|
||||
Delete(name string) error
|
||||
Watch(label labels.Selector, field fields.Selector, opts api.ListOptions) (watch.Interface, error)
|
||||
ProxyGet(name, path string, params map[string]string) ResponseWrapper
|
||||
ProxyGet(scheme, name, port, path string, params map[string]string) ResponseWrapper
|
||||
}
|
||||
|
||||
// services implements ServicesNamespacer interface
|
||||
@@ -102,12 +103,12 @@ func (c *services) Watch(label labels.Selector, field fields.Selector, opts api.
|
||||
}
|
||||
|
||||
// ProxyGet returns a response of the service by calling it through the proxy.
|
||||
func (c *services) ProxyGet(name, path string, params map[string]string) ResponseWrapper {
|
||||
func (c *services) ProxyGet(scheme, name, port, path string, params map[string]string) ResponseWrapper {
|
||||
request := c.r.Get().
|
||||
Prefix("proxy").
|
||||
Namespace(c.ns).
|
||||
Resource("services").
|
||||
Name(name).
|
||||
Name(util.JoinSchemeNamePort(scheme, name, port)).
|
||||
Suffix(path)
|
||||
for k, v := range params {
|
||||
request = request.Param(k, v)
|
||||
|
||||
@@ -166,6 +166,18 @@ func TestServiceProxyGet(t *testing.T) {
|
||||
},
|
||||
Response: Response{StatusCode: 200, RawBody: &body},
|
||||
}
|
||||
response, err := c.Setup(t).Services(ns).ProxyGet("service-1", "foo", map[string]string{"param-name": "param-value"}).DoRaw()
|
||||
response, err := c.Setup(t).Services(ns).ProxyGet("", "service-1", "", "foo", map[string]string{"param-name": "param-value"}).DoRaw()
|
||||
c.ValidateRaw(t, response, err)
|
||||
|
||||
// With scheme and port specified
|
||||
c = &testClient{
|
||||
Request: testRequest{
|
||||
Method: "GET",
|
||||
Path: testapi.Default.ResourcePathWithPrefix("proxy", "services", ns, "https:service-1:my-port") + "/foo",
|
||||
Query: buildQueryValues(url.Values{"param-name": []string{"param-value"}}),
|
||||
},
|
||||
Response: 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()
|
||||
c.ValidateRaw(t, response, err)
|
||||
}
|
||||
|
||||
@@ -169,12 +169,14 @@ func NewWatchAction(resource, namespace string, label labels.Selector, field fie
|
||||
return action
|
||||
}
|
||||
|
||||
func NewProxyGetAction(resource, namespace, name, path string, params map[string]string) ProxyGetActionImpl {
|
||||
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
|
||||
@@ -235,7 +237,9 @@ type WatchAction interface {
|
||||
|
||||
type ProxyGetAction interface {
|
||||
Action
|
||||
GetScheme() string
|
||||
GetName() string
|
||||
GetPort() string
|
||||
GetPath() string
|
||||
GetParams() map[string]string
|
||||
}
|
||||
@@ -338,15 +342,25 @@ func (a WatchActionImpl) GetWatchRestrictions() 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
|
||||
}
|
||||
|
||||
@@ -76,6 +76,6 @@ func (c *FakeServices) Watch(label labels.Selector, field fields.Selector, opts
|
||||
return c.Fake.InvokesWatch(NewWatchAction("services", c.Namespace, label, field, opts))
|
||||
}
|
||||
|
||||
func (c *FakeServices) ProxyGet(name, path string, params map[string]string) unversioned.ResponseWrapper {
|
||||
return c.Fake.InvokesProxy(NewProxyGetAction("services", c.Namespace, name, path, params))
|
||||
func (c *FakeServices) ProxyGet(scheme, name, port, path string, params map[string]string) unversioned.ResponseWrapper {
|
||||
return c.Fake.InvokesProxy(NewProxyGetAction("services", c.Namespace, scheme, name, port, path, params))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user