func (registry *MemoryRegistry) ListPods(query labels.Query) ([]api.Pod, error) { result := []api.Pod{} for _, value := range registry.podData { if query.Matches(labels.Set(value.Labels)) { result = append(result, value) } } return result, nil }
func (storage *ControllerRegistryStorage) List(query labels.Query) (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)) { result.Items = append(result.Items, controller) } } } return result, err }
func (registry *MockPodRegistry) ListPods(query labels.Query) ([]api.Pod, error) { if registry.err != nil { return registry.pods, registry.err } var filtered []api.Pod for _, pod := range registry.pods { if query.Matches(labels.Set(pod.Labels)) { filtered = append(filtered, pod) } } return filtered, nil }
func (sr *ServiceRegistryStorage) List(query labels.Query) (interface{}, error) { list, err := sr.registry.ListServices() if err != nil { return nil, err } list.Kind = "cluster#serviceList" var filtered []api.Service for _, service := range list.Items { if query.Matches(labels.Set(service.Labels)) { filtered = append(filtered, service) } } list.Items = filtered return list, err }
func (registry *EtcdRegistry) ListPods(query labels.Query) ([]api.Pod, error) { pods := []api.Pod{} for _, machine := range registry.machines { var machinePods []api.Pod err := registry.extractList("/registry/hosts/"+machine+"/pods", &machinePods) if err != nil { return pods, err } for _, pod := range machinePods { if query.Matches(labels.Set(pod.Labels)) { pod.CurrentState.Host = machine pods = append(pods, pod) } } } return pods, nil }