Rename [label] query to selector
This commit is contained in:
@@ -35,12 +35,12 @@ func MakeControllerRegistryStorage(registry ControllerRegistry) apiserver.RESTSt
|
||||
}
|
||||
}
|
||||
|
||||
func (storage *ControllerRegistryStorage) List(query labels.Query) (interface{}, error) {
|
||||
func (storage *ControllerRegistryStorage) List(selector labels.Selector) (interface{}, error) {
|
||||
result := api.ReplicationControllerList{JSONBase: api.JSONBase{Kind: "cluster#replicationControllerList"}}
|
||||
controllers, err := storage.registry.ListControllers()
|
||||
if err == nil {
|
||||
for _, controller := range controllers {
|
||||
if query.Matches(labels.Set(controller.Labels)) {
|
||||
if selector.Matches(labels.Set(controller.Labels)) {
|
||||
result.Items = append(result.Items, controller)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func (e *EndpointController) SyncServiceEndpoints() error {
|
||||
}
|
||||
var resultErr error
|
||||
for _, service := range services.Items {
|
||||
pods, err := e.podRegistry.ListPods(labels.Set(service.Selector).AsQuery())
|
||||
pods, err := e.podRegistry.ListPods(labels.Set(service.Selector).AsSelector())
|
||||
if err != nil {
|
||||
log.Printf("Error syncing service: %#v, skipping.", service)
|
||||
resultErr = err
|
||||
|
||||
@@ -59,7 +59,7 @@ func (registry *EtcdRegistry) helper() *util.EtcdHelper {
|
||||
return &util.EtcdHelper{registry.etcdClient}
|
||||
}
|
||||
|
||||
func (registry *EtcdRegistry) ListPods(query labels.Query) ([]api.Pod, error) {
|
||||
func (registry *EtcdRegistry) ListPods(selector labels.Selector) ([]api.Pod, error) {
|
||||
pods := []api.Pod{}
|
||||
for _, machine := range registry.machines {
|
||||
var machinePods []api.Pod
|
||||
@@ -68,7 +68,7 @@ func (registry *EtcdRegistry) ListPods(query labels.Query) ([]api.Pod, error) {
|
||||
return pods, err
|
||||
}
|
||||
for _, pod := range machinePods {
|
||||
if query.Matches(labels.Set(pod.Labels)) {
|
||||
if selector.Matches(labels.Set(pod.Labels)) {
|
||||
pod.CurrentState.Host = machine
|
||||
pods = append(pods, pod)
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
|
||||
// PodRegistry is an interface implemented by things that know how to store Pod objects.
|
||||
type PodRegistry interface {
|
||||
// ListPods obtains a list of pods that match query.
|
||||
ListPods(query labels.Query) ([]api.Pod, error)
|
||||
// ListPods obtains a list of pods that match selector.
|
||||
ListPods(selector labels.Selector) ([]api.Pod, error)
|
||||
// Get a specific pod
|
||||
GetPod(podID string) (*api.Pod, error)
|
||||
// Create a pod based on a specification, schedule it onto a specific machine.
|
||||
|
||||
@@ -36,10 +36,10 @@ func MakeMemoryRegistry() *MemoryRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
func (registry *MemoryRegistry) ListPods(query labels.Query) ([]api.Pod, error) {
|
||||
func (registry *MemoryRegistry) ListPods(selector labels.Selector) ([]api.Pod, error) {
|
||||
result := []api.Pod{}
|
||||
for _, value := range registry.podData {
|
||||
if query.Matches(labels.Set(value.Labels)) {
|
||||
if selector.Matches(labels.Set(value.Labels)) {
|
||||
result = append(result, value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@ func MakePodRegistryStorage(registry PodRegistry, containerInfo client.Container
|
||||
}
|
||||
}
|
||||
|
||||
func (storage *PodRegistryStorage) List(query labels.Query) (interface{}, error) {
|
||||
func (storage *PodRegistryStorage) List(selector labels.Selector) (interface{}, error) {
|
||||
var result api.PodList
|
||||
pods, err := storage.registry.ListPods(query)
|
||||
pods, err := storage.registry.ListPods(selector)
|
||||
if err == nil {
|
||||
result.Items = pods
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func GetServiceEnvironmentVariables(registry ServiceRegistry, machine string) ([
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (sr *ServiceRegistryStorage) List(query labels.Query) (interface{}, error) {
|
||||
func (sr *ServiceRegistryStorage) List(selector labels.Selector) (interface{}, error) {
|
||||
list, err := sr.registry.ListServices()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -67,7 +67,7 @@ func (sr *ServiceRegistryStorage) List(query labels.Query) (interface{}, error)
|
||||
list.Kind = "cluster#serviceList"
|
||||
var filtered []api.Service
|
||||
for _, service := range list.Items {
|
||||
if query.Matches(labels.Set(service.Labels)) {
|
||||
if selector.Matches(labels.Set(service.Labels)) {
|
||||
filtered = append(filtered, service)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user