mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-29 21:29:24 +00:00
Refactor: separate KubeletClient & ConnectionInfoGetter concepts
KubeletClient implements ConnectionInfoGetter, but it is not a complete implementation: it does not set the kubelet port from the node record, for example. By renaming the method so that it does not implement the interface, we are able to cleanly see where the "raw" GetConnectionInfo is used (it is correct) and also have go type-checking enforce this for us.
This commit is contained in:
@@ -41,7 +41,7 @@ type NodeStorage struct {
|
||||
|
||||
type REST struct {
|
||||
*registry.Store
|
||||
connection client.ConnectionInfoGetter
|
||||
connection client.KubeletClient
|
||||
proxyTransport http.RoundTripper
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func (r *StatusREST) Update(ctx api.Context, name string, objInfo rest.UpdatedOb
|
||||
}
|
||||
|
||||
// NewStorage returns a NodeStorage object that will work against nodes.
|
||||
func NewStorage(opts generic.RESTOptions, connection client.ConnectionInfoGetter, proxyTransport http.RoundTripper) NodeStorage {
|
||||
func NewStorage(opts generic.RESTOptions, connection client.KubeletClient, proxyTransport http.RoundTripper) NodeStorage {
|
||||
prefix := "/" + opts.ResourcePrefix
|
||||
|
||||
newListFunc := func() runtime.Object { return &api.NodeList{} }
|
||||
@@ -140,7 +140,7 @@ func (r *REST) getKubeletPort(ctx api.Context, nodeName string) (int, error) {
|
||||
}
|
||||
|
||||
func (c *REST) GetConnectionInfo(ctx api.Context, nodeName string) (string, uint, http.RoundTripper, error) {
|
||||
scheme, port, transport, err := c.connection.GetConnectionInfo(ctx, nodeName)
|
||||
scheme, port, transport, err := c.connection.GetRawConnectionInfo(ctx, nodeName)
|
||||
if err != nil {
|
||||
return "", 0, nil, err
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
type fakeConnectionInfoGetter struct {
|
||||
}
|
||||
|
||||
func (fakeConnectionInfoGetter) GetConnectionInfo(ctx api.Context, nodeName string) (string, uint, http.RoundTripper, error) {
|
||||
func (fakeConnectionInfoGetter) GetRawConnectionInfo(ctx api.Context, nodeName string) (string, uint, http.RoundTripper, error) {
|
||||
return "http", 12345, nil, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user