mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
use New instead of Make and add comments to make golint happy
This commit is contained in:
parent
e53658a3ed
commit
bcbdbf6558
@ -87,7 +87,7 @@ func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInf
|
|||||||
s := scheduler.MakeFirstFitScheduler(m.podRegistry, m.random)
|
s := scheduler.MakeFirstFitScheduler(m.podRegistry, m.random)
|
||||||
m.storage = map[string]apiserver.RESTStorage{
|
m.storage = map[string]apiserver.RESTStorage{
|
||||||
"pods": registry.MakePodRegistryStorage(m.podRegistry, podInfoGetter, s, m.minionRegistry, cloud, podCache),
|
"pods": registry.MakePodRegistryStorage(m.podRegistry, podInfoGetter, s, m.minionRegistry, cloud, podCache),
|
||||||
"replicationControllers": registry.MakeControllerRegistryStorage(m.controllerRegistry, m.podRegistry),
|
"replicationControllers": registry.NewControllerRegistryStorage(m.controllerRegistry, m.podRegistry),
|
||||||
"services": registry.MakeServiceRegistryStorage(m.serviceRegistry, cloud, m.minionRegistry),
|
"services": registry.MakeServiceRegistryStorage(m.serviceRegistry, cloud, m.minionRegistry),
|
||||||
"minions": registry.MakeMinionRegistryStorage(m.minionRegistry),
|
"minions": registry.MakeMinionRegistryStorage(m.minionRegistry),
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Implementation of RESTStorage for the api server.
|
// ControllerRegistryStorage is an implementation of RESTStorage for the api server.
|
||||||
type ControllerRegistryStorage struct {
|
type ControllerRegistryStorage struct {
|
||||||
registry ControllerRegistry
|
registry ControllerRegistry
|
||||||
podRegistry PodRegistry
|
podRegistry PodRegistry
|
||||||
@ -33,7 +33,8 @@ type ControllerRegistryStorage struct {
|
|||||||
pollPeriod time.Duration
|
pollPeriod time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeControllerRegistryStorage(registry ControllerRegistry, podRegistry PodRegistry) apiserver.RESTStorage {
|
// NewControllerRegistryStorage creates a new NewControllerRegistryStorage instance.
|
||||||
|
func NewControllerRegistryStorage(registry ControllerRegistry, podRegistry PodRegistry) apiserver.RESTStorage {
|
||||||
return &ControllerRegistryStorage{
|
return &ControllerRegistryStorage{
|
||||||
registry: registry,
|
registry: registry,
|
||||||
podRegistry: podRegistry,
|
podRegistry: podRegistry,
|
||||||
@ -41,6 +42,7 @@ func MakeControllerRegistryStorage(registry ControllerRegistry, podRegistry PodR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List obtains a list of ReplicationControllers that match selector.
|
||||||
func (storage *ControllerRegistryStorage) List(selector labels.Selector) (interface{}, error) {
|
func (storage *ControllerRegistryStorage) List(selector labels.Selector) (interface{}, error) {
|
||||||
result := api.ReplicationControllerList{}
|
result := api.ReplicationControllerList{}
|
||||||
controllers, err := storage.registry.ListControllers()
|
controllers, err := storage.registry.ListControllers()
|
||||||
@ -54,6 +56,7 @@ func (storage *ControllerRegistryStorage) List(selector labels.Selector) (interf
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get obtains the ReplicationController specified by its id.
|
||||||
func (storage *ControllerRegistryStorage) Get(id string) (interface{}, error) {
|
func (storage *ControllerRegistryStorage) Get(id string) (interface{}, error) {
|
||||||
controller, err := storage.registry.GetController(id)
|
controller, err := storage.registry.GetController(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -62,18 +65,21 @@ func (storage *ControllerRegistryStorage) Get(id string) (interface{}, error) {
|
|||||||
return controller, err
|
return controller, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete asynchronously deletes the ReplicationController specified by its id.
|
||||||
func (storage *ControllerRegistryStorage) Delete(id string) (<-chan interface{}, error) {
|
func (storage *ControllerRegistryStorage) Delete(id string) (<-chan interface{}, error) {
|
||||||
return apiserver.MakeAsync(func() (interface{}, error) {
|
return apiserver.MakeAsync(func() (interface{}, error) {
|
||||||
return api.Status{Status: api.StatusSuccess}, storage.registry.DeleteController(id)
|
return api.Status{Status: api.StatusSuccess}, storage.registry.DeleteController(id)
|
||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract deserializes user provided data into an api.ReplicationController.
|
||||||
func (storage *ControllerRegistryStorage) Extract(body []byte) (interface{}, error) {
|
func (storage *ControllerRegistryStorage) Extract(body []byte) (interface{}, error) {
|
||||||
result := api.ReplicationController{}
|
result := api.ReplicationController{}
|
||||||
err := api.DecodeInto(body, &result)
|
err := api.DecodeInto(body, &result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create registers a given new ReplicationController instance to storage.registry.
|
||||||
func (storage *ControllerRegistryStorage) Create(obj interface{}) (<-chan interface{}, error) {
|
func (storage *ControllerRegistryStorage) Create(obj interface{}) (<-chan interface{}, error) {
|
||||||
controller, ok := obj.(api.ReplicationController)
|
controller, ok := obj.(api.ReplicationController)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -91,6 +97,7 @@ func (storage *ControllerRegistryStorage) Create(obj interface{}) (<-chan interf
|
|||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update replaces a given ReplicationController instance with an existing instnace in storage.registry.
|
||||||
func (storage *ControllerRegistryStorage) Update(obj interface{}) (<-chan interface{}, error) {
|
func (storage *ControllerRegistryStorage) Update(obj interface{}) (<-chan interface{}, error) {
|
||||||
controller, ok := obj.(api.ReplicationController)
|
controller, ok := obj.(api.ReplicationController)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -35,7 +35,7 @@ type PodRegistry interface {
|
|||||||
DeletePod(podID string) error
|
DeletePod(podID string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// ControllerRegistry is an interface for things that know how to store Controllers.
|
// ControllerRegistry is an interface for things that know how to store ReplicationControllers.
|
||||||
type ControllerRegistry interface {
|
type ControllerRegistry interface {
|
||||||
ListControllers() ([]api.ReplicationController, error)
|
ListControllers() ([]api.ReplicationController, error)
|
||||||
GetController(controllerID string) (*api.ReplicationController, error)
|
GetController(controllerID string) (*api.ReplicationController, error)
|
||||||
|
Loading…
Reference in New Issue
Block a user