mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Nodes returns transport and scheme in spite of port requirements
This commit is contained in:
parent
640c40da65
commit
b678e2ff9e
@ -129,7 +129,7 @@ func MatchNode(label labels.Selector, field fields.Selector) generic.Matcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResourceLocation returns a URL to which one can send traffic for the specified node.
|
// ResourceLocation returns an URL and transport which one can use to send traffic for the specified node.
|
||||||
func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGetter, ctx api.Context, id string) (*url.URL, http.RoundTripper, error) {
|
func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGetter, ctx api.Context, id string) (*url.URL, http.RoundTripper, error) {
|
||||||
name, portReq, valid := util.SplitPort(id)
|
name, portReq, valid := util.SplitPort(id)
|
||||||
if !valid {
|
if !valid {
|
||||||
@ -143,15 +143,15 @@ func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGet
|
|||||||
node := nodeObj.(*api.Node)
|
node := nodeObj.(*api.Node)
|
||||||
host := node.Name // TODO: use node's IP, don't expect the name to resolve.
|
host := node.Name // TODO: use node's IP, don't expect the name to resolve.
|
||||||
|
|
||||||
if portReq != "" {
|
|
||||||
return &url.URL{Host: net.JoinHostPort(host, portReq)}, nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
scheme, port, transport, err := connection.GetConnectionInfo(host)
|
scheme, port, transport, err := connection.GetConnectionInfo(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if portReq != "" {
|
||||||
|
return &url.URL{Scheme: scheme, Host: net.JoinHostPort(host, portReq)}, transport, nil
|
||||||
|
}
|
||||||
|
|
||||||
return &url.URL{
|
return &url.URL{
|
||||||
Scheme: scheme,
|
Scheme: scheme,
|
||||||
Host: net.JoinHostPort(
|
Host: net.JoinHostPort(
|
||||||
|
Loading…
Reference in New Issue
Block a user