mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 06:32:32 +00:00
Fixes golint errors in pkg/master
This commit is contained in:
@@ -43,7 +43,7 @@ type Master struct {
|
||||
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 {
|
||||
m := &Master{
|
||||
podRegistry: registry.MakeMemoryRegistry(),
|
||||
@@ -55,7 +55,7 @@ func NewMemoryServer(minions []string, podInfoGetter client.PodInfoGetter, cloud
|
||||
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 {
|
||||
etcdClient := etcd.NewClient(etcdServers)
|
||||
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 {
|
||||
endpoints := registry.MakeEndpointController(m.serviceRegistry, m.podRegistry)
|
||||
go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)
|
||||
@@ -109,8 +109,9 @@ func (m *Master) Run(myAddress, apiPrefix string) error {
|
||||
return s.ListenAndServe()
|
||||
}
|
||||
|
||||
// Instead of calling Run, call ConstructHandler to get a handler for your own
|
||||
// server. Intended for testing. Only call once.
|
||||
// ConstructHandler returns an http.Handler which serves Kubernetes API.
|
||||
// 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 {
|
||||
endpoints := registry.MakeEndpointController(m.serviceRegistry, m.podRegistry)
|
||||
go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)
|
||||
|
@@ -40,6 +40,7 @@ type PodCache struct {
|
||||
podLock sync.Mutex
|
||||
}
|
||||
|
||||
// NewPodCache returns a new PodCache.
|
||||
func NewPodCache(info client.PodInfoGetter, pods registry.PodRegistry, period time.Duration) *PodCache {
|
||||
return &PodCache{
|
||||
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.
|
||||
func (p *PodCache) GetPodInfo(host, podID string) (api.PodInfo, error) {
|
||||
p.podLock.Lock()
|
||||
@@ -57,9 +58,8 @@ func (p *PodCache) GetPodInfo(host, podID string) (api.PodInfo, error) {
|
||||
value, ok := p.podInfo[podID]
|
||||
if !ok {
|
||||
return nil, errors.New("No cached pod info")
|
||||
} else {
|
||||
return value, nil
|
||||
}
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func (p *PodCache) updatePodInfo(host, id string) error {
|
||||
@@ -73,7 +73,7 @@ func (p *PodCache) updatePodInfo(host, id string) error {
|
||||
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() {
|
||||
pods, err := p.pods.ListPods(labels.Everything())
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user