Fixes golint errors in pkg/master
This commit is contained in:
@@ -43,7 +43,7 @@ type Master struct {
|
|||||||
storage map[string]apiserver.RESTStorage
|
storage map[string]apiserver.RESTStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a memory (not etcd) backed apiserver.
|
// NewMemoryServer returns a memory (not etcd) backed apiserver.
|
||||||
func NewMemoryServer(minions []string, podInfoGetter client.PodInfoGetter, cloud cloudprovider.Interface) *Master {
|
func NewMemoryServer(minions []string, podInfoGetter client.PodInfoGetter, cloud cloudprovider.Interface) *Master {
|
||||||
m := &Master{
|
m := &Master{
|
||||||
podRegistry: registry.MakeMemoryRegistry(),
|
podRegistry: registry.MakeMemoryRegistry(),
|
||||||
@@ -55,7 +55,7 @@ func NewMemoryServer(minions []string, podInfoGetter client.PodInfoGetter, cloud
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a new apiserver.
|
// New returns a new apiserver.
|
||||||
func New(etcdServers, minions []string, podInfoGetter client.PodInfoGetter, cloud cloudprovider.Interface, minionRegexp string) *Master {
|
func New(etcdServers, minions []string, podInfoGetter client.PodInfoGetter, cloud cloudprovider.Interface, minionRegexp string) *Master {
|
||||||
etcdClient := etcd.NewClient(etcdServers)
|
etcdClient := etcd.NewClient(etcdServers)
|
||||||
minionRegistry := minionRegistryMaker(minions, cloud, minionRegexp)
|
minionRegistry := minionRegistryMaker(minions, cloud, minionRegexp)
|
||||||
@@ -94,7 +94,7 @@ func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInf
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Runs master. Never returns.
|
// Run runs master. Never returns.
|
||||||
func (m *Master) Run(myAddress, apiPrefix string) error {
|
func (m *Master) Run(myAddress, apiPrefix string) error {
|
||||||
endpoints := registry.MakeEndpointController(m.serviceRegistry, m.podRegistry)
|
endpoints := registry.MakeEndpointController(m.serviceRegistry, m.podRegistry)
|
||||||
go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)
|
go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)
|
||||||
@@ -109,8 +109,9 @@ func (m *Master) Run(myAddress, apiPrefix string) error {
|
|||||||
return s.ListenAndServe()
|
return s.ListenAndServe()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instead of calling Run, call ConstructHandler to get a handler for your own
|
// ConstructHandler returns an http.Handler which serves Kubernetes API.
|
||||||
// server. Intended for testing. Only call once.
|
// Instead of calling Run, you can call this function to get a handler for your own server.
|
||||||
|
// Intended for testing. Only call once.
|
||||||
func (m *Master) ConstructHandler(apiPrefix string) http.Handler {
|
func (m *Master) ConstructHandler(apiPrefix string) http.Handler {
|
||||||
endpoints := registry.MakeEndpointController(m.serviceRegistry, m.podRegistry)
|
endpoints := registry.MakeEndpointController(m.serviceRegistry, m.podRegistry)
|
||||||
go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)
|
go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)
|
||||||
|
@@ -40,6 +40,7 @@ type PodCache struct {
|
|||||||
podLock sync.Mutex
|
podLock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewPodCache returns a new PodCache.
|
||||||
func NewPodCache(info client.PodInfoGetter, pods registry.PodRegistry, period time.Duration) *PodCache {
|
func NewPodCache(info client.PodInfoGetter, pods registry.PodRegistry, period time.Duration) *PodCache {
|
||||||
return &PodCache{
|
return &PodCache{
|
||||||
containerInfo: info,
|
containerInfo: info,
|
||||||
@@ -49,7 +50,7 @@ func NewPodCache(info client.PodInfoGetter, pods registry.PodRegistry, period ti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements the PodInfoGetter interface.
|
// GetPodInfo Implements the PodInfoGetter.GetPodInfo.
|
||||||
// The returned value should be treated as read-only.
|
// The returned value should be treated as read-only.
|
||||||
func (p *PodCache) GetPodInfo(host, podID string) (api.PodInfo, error) {
|
func (p *PodCache) GetPodInfo(host, podID string) (api.PodInfo, error) {
|
||||||
p.podLock.Lock()
|
p.podLock.Lock()
|
||||||
@@ -57,9 +58,8 @@ func (p *PodCache) GetPodInfo(host, podID string) (api.PodInfo, error) {
|
|||||||
value, ok := p.podInfo[podID]
|
value, ok := p.podInfo[podID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.New("No cached pod info")
|
return nil, errors.New("No cached pod info")
|
||||||
} else {
|
|
||||||
return value, nil
|
|
||||||
}
|
}
|
||||||
|
return value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PodCache) updatePodInfo(host, id string) error {
|
func (p *PodCache) updatePodInfo(host, id string) error {
|
||||||
@@ -73,7 +73,7 @@ func (p *PodCache) updatePodInfo(host, id string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update information about all containers. Either called by Loop() below, or one-off.
|
// UpdateAllContainers updates information about all containers. Either called by Loop() below, or one-off.
|
||||||
func (p *PodCache) UpdateAllContainers() {
|
func (p *PodCache) UpdateAllContainers() {
|
||||||
pods, err := p.pods.ListPods(labels.Everything())
|
pods, err := p.pods.ListPods(labels.Everything())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user