From e53658a3ed1236ce0835378de2a21e9ac9265ee3 Mon Sep 17 00:00:00 2001 From: Kouhei Ueno Date: Fri, 11 Jul 2014 22:08:53 +0900 Subject: [PATCH 1/3] s/controllerId/controllerID/ to make golint happy. --- pkg/registry/interfaces.go | 4 ++-- pkg/registry/memory_registry.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/registry/interfaces.go b/pkg/registry/interfaces.go index f3190b18da4..3a6752509bd 100644 --- a/pkg/registry/interfaces.go +++ b/pkg/registry/interfaces.go @@ -38,10 +38,10 @@ type PodRegistry interface { // ControllerRegistry is an interface for things that know how to store Controllers. type ControllerRegistry interface { ListControllers() ([]api.ReplicationController, error) - GetController(controllerId string) (*api.ReplicationController, error) + GetController(controllerID string) (*api.ReplicationController, error) CreateController(controller api.ReplicationController) error UpdateController(controller api.ReplicationController) error - DeleteController(controllerId string) error + DeleteController(controllerID string) error } // ServiceRegistry is an interface for things that know how to store services. diff --git a/pkg/registry/memory_registry.go b/pkg/registry/memory_registry.go index bd0e25cf103..63dee81d0cb 100644 --- a/pkg/registry/memory_registry.go +++ b/pkg/registry/memory_registry.go @@ -93,8 +93,8 @@ func (registry *MemoryRegistry) CreateController(controller api.ReplicationContr return nil } -func (registry *MemoryRegistry) DeleteController(controllerId string) error { - delete(registry.controllerData, controllerId) +func (registry *MemoryRegistry) DeleteController(controllerID string) error { + delete(registry.controllerData, controllerID) return nil } From bcbdbf6558b18ff8c52ec3bf2865f3e2ee35c514 Mon Sep 17 00:00:00 2001 From: Kouhei Ueno Date: Fri, 11 Jul 2014 22:46:22 +0900 Subject: [PATCH 2/3] use New instead of Make and add comments to make golint happy --- pkg/master/master.go | 2 +- pkg/registry/controller_registry.go | 11 +++++++++-- pkg/registry/interfaces.go | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/master/master.go b/pkg/master/master.go index 5b17457fcb3..80831fa095e 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -87,7 +87,7 @@ func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInf s := scheduler.MakeFirstFitScheduler(m.podRegistry, m.random) m.storage = map[string]apiserver.RESTStorage{ "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), "minions": registry.MakeMinionRegistryStorage(m.minionRegistry), } diff --git a/pkg/registry/controller_registry.go b/pkg/registry/controller_registry.go index 296ce9c756a..a43fc51fd57 100644 --- a/pkg/registry/controller_registry.go +++ b/pkg/registry/controller_registry.go @@ -25,7 +25,7 @@ import ( "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 { registry ControllerRegistry podRegistry PodRegistry @@ -33,7 +33,8 @@ type ControllerRegistryStorage struct { 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{ registry: registry, 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) { result := api.ReplicationControllerList{} controllers, err := storage.registry.ListControllers() @@ -54,6 +56,7 @@ func (storage *ControllerRegistryStorage) List(selector labels.Selector) (interf return result, err } +// Get obtains the ReplicationController specified by its id. func (storage *ControllerRegistryStorage) Get(id string) (interface{}, error) { controller, err := storage.registry.GetController(id) if err != nil { @@ -62,18 +65,21 @@ func (storage *ControllerRegistryStorage) Get(id string) (interface{}, error) { return controller, err } +// Delete asynchronously deletes the ReplicationController specified by its id. func (storage *ControllerRegistryStorage) Delete(id string) (<-chan interface{}, error) { return apiserver.MakeAsync(func() (interface{}, error) { return api.Status{Status: api.StatusSuccess}, storage.registry.DeleteController(id) }), nil } +// Extract deserializes user provided data into an api.ReplicationController. func (storage *ControllerRegistryStorage) Extract(body []byte) (interface{}, error) { result := api.ReplicationController{} err := api.DecodeInto(body, &result) return result, err } +// Create registers a given new ReplicationController instance to storage.registry. func (storage *ControllerRegistryStorage) Create(obj interface{}) (<-chan interface{}, error) { controller, ok := obj.(api.ReplicationController) if !ok { @@ -91,6 +97,7 @@ func (storage *ControllerRegistryStorage) Create(obj interface{}) (<-chan interf }), nil } +// Update replaces a given ReplicationController instance with an existing instnace in storage.registry. func (storage *ControllerRegistryStorage) Update(obj interface{}) (<-chan interface{}, error) { controller, ok := obj.(api.ReplicationController) if !ok { diff --git a/pkg/registry/interfaces.go b/pkg/registry/interfaces.go index 3a6752509bd..4c52195625d 100644 --- a/pkg/registry/interfaces.go +++ b/pkg/registry/interfaces.go @@ -35,7 +35,7 @@ type PodRegistry interface { 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 { ListControllers() ([]api.ReplicationController, error) GetController(controllerID string) (*api.ReplicationController, error) From f93289142859ba66c000d7b1647498d0e555894a Mon Sep 17 00:00:00 2001 From: Kouhei Ueno Date: Sat, 12 Jul 2014 13:21:48 +0900 Subject: [PATCH 3/3] removes a comment on New and a typo fix --- pkg/registry/controller_registry.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/registry/controller_registry.go b/pkg/registry/controller_registry.go index a43fc51fd57..ae59cd37ec0 100644 --- a/pkg/registry/controller_registry.go +++ b/pkg/registry/controller_registry.go @@ -33,7 +33,6 @@ type ControllerRegistryStorage struct { pollPeriod time.Duration } -// NewControllerRegistryStorage creates a new NewControllerRegistryStorage instance. func NewControllerRegistryStorage(registry ControllerRegistry, podRegistry PodRegistry) apiserver.RESTStorage { return &ControllerRegistryStorage{ registry: registry, @@ -97,7 +96,7 @@ func (storage *ControllerRegistryStorage) Create(obj interface{}) (<-chan interf }), nil } -// Update replaces a given ReplicationController instance with an existing instnace in storage.registry. +// Update replaces a given ReplicationController instance with an existing instance in storage.registry. func (storage *ControllerRegistryStorage) Update(obj interface{}) (<-chan interface{}, error) { controller, ok := obj.(api.ReplicationController) if !ok {