ListMinions support for selectors

pull/6/head
Wojciech Tyczynski 2015-04-09 14:22:09 +02:00
parent 6ef0f8c3c5
commit 0e5b478b4d
5 changed files with 9 additions and 7 deletions

View File

@ -41,6 +41,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/handlers"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/master/ports"
controlleretcd "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/controller/etcd"
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/endpoint"
@ -567,7 +569,7 @@ func (m *Master) getServersToValidate(c *Config) map[string]apiserver.Server {
}
serversToValidate[fmt.Sprintf("etcd-%d", ix)] = apiserver.Server{Addr: addr, Port: port, Path: "/v2/keys/"}
}
nodes, err := m.nodeRegistry.ListMinions(api.NewDefaultContext())
nodes, err := m.nodeRegistry.ListMinions(api.NewDefaultContext(), labels.Everything(), fields.Everything())
if err != nil {
glog.Errorf("Failed to list minions: %v", err)
}

View File

@ -26,7 +26,7 @@ import (
// Registry is an interface for things that know how to store node.
type Registry interface {
ListMinions(ctx api.Context) (*api.NodeList, error)
ListMinions(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error)
CreateMinion(ctx api.Context, minion *api.Node) error
UpdateMinion(ctx api.Context, minion *api.Node) error
GetMinion(ctx api.Context, minionID string) (*api.Node, error)
@ -45,8 +45,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s}
}
func (s *storage) ListMinions(ctx api.Context) (*api.NodeList, error) {
obj, err := s.List(ctx, labels.Everything(), fields.Everything())
func (s *storage) ListMinions(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error) {
obj, err := s.List(ctx, label, field)
if err != nil {
return nil, err
}

View File

@ -27,7 +27,7 @@ import (
// Registry is an interface implemented by things that know how to store Pod objects.
type Registry interface {
// ListPods obtains a list of pods having labels which match selector.
ListPods(ctx api.Context, selector labels.Selector) (*api.PodList, error)
ListPods(ctx api.Context, label labels.Selector) (*api.PodList, error)
// Watch for new/changed/deleted pods
WatchPods(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
// Get a specific pod

View File

@ -59,7 +59,7 @@ func (r *MinionRegistry) SetError(err error) {
r.Err = err
}
func (r *MinionRegistry) ListMinions(ctx api.Context) (*api.NodeList, error) {
func (r *MinionRegistry) ListMinions(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error) {
r.Lock()
defer r.Unlock()
return &r.Minions, r.Err

View File

@ -295,7 +295,7 @@ func (rs *REST) createExternalLoadBalancer(ctx api.Context, service *api.Service
if !ok {
return fmt.Errorf("the cloud provider does not support zone enumeration.")
}
hosts, err := rs.machines.ListMinions(ctx)
hosts, err := rs.machines.ListMinions(ctx, labels.Everything(), fields.Everything())
if err != nil {
return err
}