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:
Justin Santa Barbara
2016-07-15 12:00:11 -04:00
parent faac71c0dc
commit 7381e9ac37
4 changed files with 9 additions and 9 deletions

View File

@@ -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
}

View File

@@ -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
}