Make KubeletClient public
This commit is contained in:
@@ -21,7 +21,7 @@ import (
|
||||
|
||||
type FactoryApi interface {
|
||||
GetForInstance(instance *types.Instance) (*kubernetes.Clientset, error)
|
||||
GetKubeletForInstance(instance *types.Instance) (*kubeletClient, error)
|
||||
GetKubeletForInstance(instance *types.Instance) (*KubeletClient, error)
|
||||
}
|
||||
|
||||
func NewClient(instance *types.Instance, proxyHost string) (*kubernetes.Clientset, error) {
|
||||
@@ -75,7 +75,7 @@ func NewClient(instance *types.Instance, proxyHost string) (*kubernetes.Clientse
|
||||
return kubernetes.New(rc), nil
|
||||
}
|
||||
|
||||
func NewKubeletClient(instance *types.Instance, proxyHost string) (*kubeletClient, error) {
|
||||
func NewKubeletClient(instance *types.Instance, proxyHost string) (*KubeletClient, error) {
|
||||
var durl string
|
||||
|
||||
host := router.EncodeHost(instance.SessionId, instance.RoutableIP, router.HostOpts{EncodedPort: 10255})
|
||||
@@ -94,16 +94,16 @@ func NewKubeletClient(instance *types.Instance, proxyHost string) (*kubeletClien
|
||||
cli := &http.Client{
|
||||
Transport: transport,
|
||||
}
|
||||
kc := &kubeletClient{client: cli, baseURL: durl}
|
||||
kc := &KubeletClient{client: cli, baseURL: durl}
|
||||
return kc, nil
|
||||
}
|
||||
|
||||
type kubeletClient struct {
|
||||
type KubeletClient struct {
|
||||
client *http.Client
|
||||
baseURL string
|
||||
}
|
||||
|
||||
func (c *kubeletClient) Get(path string) (*http.Response, error) {
|
||||
func (c *KubeletClient) Get(path string) (*http.Response, error) {
|
||||
return c.client.Get(c.baseURL + path)
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ type kubeletPodsResponse struct {
|
||||
Items []item
|
||||
}
|
||||
|
||||
func (c *kubeletClient) IsManager() (bool, error) {
|
||||
func (c *KubeletClient) IsManager() (bool, error) {
|
||||
res, err := c.client.Get(c.baseURL + "/pods")
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -10,9 +10,9 @@ type FactoryMock struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
func (m *FactoryMock) GetKubeletForInstance(i *types.Instance) (*kubeletClient, error) {
|
||||
func (m *FactoryMock) GetKubeletForInstance(i *types.Instance) (*KubeletClient, error) {
|
||||
args := m.Called(i)
|
||||
return args.Get(0).(*kubeletClient), args.Error(1)
|
||||
return args.Get(0).(*KubeletClient), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *FactoryMock) GetForInstance(instance *types.Instance) (*kubernetes.Clientset, error) {
|
||||
|
||||
@@ -23,7 +23,7 @@ type localCachedFactory struct {
|
||||
type instanceEntry struct {
|
||||
rw sync.Mutex
|
||||
client *kubernetes.Clientset
|
||||
kubeletClient *kubeletClient
|
||||
kubeletClient *KubeletClient
|
||||
}
|
||||
|
||||
func (f *localCachedFactory) GetForInstance(instance *types.Instance) (*kubernetes.Clientset, error) {
|
||||
@@ -60,7 +60,7 @@ func (f *localCachedFactory) GetForInstance(instance *types.Instance) (*kubernet
|
||||
return c.client, nil
|
||||
}
|
||||
|
||||
func (f *localCachedFactory) GetKubeletForInstance(instance *types.Instance) (*kubeletClient, error) {
|
||||
func (f *localCachedFactory) GetKubeletForInstance(instance *types.Instance) (*KubeletClient, error) {
|
||||
key := instance.Name
|
||||
|
||||
f.irw.Lock()
|
||||
|
||||
Reference in New Issue
Block a user