当前位置: 首页>>代码示例>>Golang>>正文


Golang api.PodList类代码示例

本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/api.PodList的典型用法代码示例。如果您正苦于以下问题:Golang PodList类的具体用法?Golang PodList怎么用?Golang PodList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PodList类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: encodePods

// encodePods creates an api.PodList object from pods and returns the encoded
// PodList.
func encodePods(pods []*api.Pod) (data []byte, err error) {
	podList := new(api.PodList)
	for _, pod := range pods {
		podList.Items = append(podList.Items, *pod)
	}
	return latest.Codec.Encode(podList)
}
开发者ID:nail-lian,项目名称:kubernetes,代码行数:9,代码来源:server.go

示例2: List

func (storage *PodRegistryStorage) List(query labels.Query) (interface{}, error) {
	var result api.PodList
	pods, err := storage.registry.ListPods(query)
	if err == nil {
		result.Items = pods
	}
	result.Kind = "cluster#podList"
	return result, err
}
开发者ID:jgeewax,项目名称:kubernetes,代码行数:9,代码来源:pod_registry.go

示例3: List

func (rs *RegistryStorage) List(selector labels.Selector) (interface{}, error) {
	var result api.PodList
	pods, err := rs.registry.ListPods(selector)
	if err == nil {
		result.Items = pods
		for i := range result.Items {
			rs.fillPodInfo(&result.Items[i])
		}
	}
	return result, err
}
开发者ID:kunallimaye,项目名称:kubernetes,代码行数:11,代码来源:storage.go

示例4: List

// Please note that selector is filtering among the pods that have gotten into
// the store; there may have been some filtering that already happened before
// that.
func (s storePodsNamespacer) List(selector labels.Selector) (pods api.PodList, err error) {
	list := api.PodList{}
	for _, m := range s.store.List() {
		pod := m.(*api.Pod)
		if s.namespace == api.NamespaceAll || s.namespace == pod.Namespace {
			if selector.Matches(labels.Set(pod.Labels)) {
				list.Items = append(list.Items, *pod)
			}
		}
	}
	return list, nil
}
开发者ID:Ima8,项目名称:kubernetes,代码行数:15,代码来源:listers.go

示例5: handlePods

// handlePods returns a list of pod bound to the Kubelet and their spec
func (s *Server) handlePods(w http.ResponseWriter, req *http.Request) {
	pods := s.host.GetPods()
	podList := new(api.PodList)
	for _, pod := range pods {
		podList.Items = append(podList.Items, *pod)
	}
	data, err := latest.Codec.Encode(podList)
	if err != nil {
		s.error(w, err)
		return
	}
	w.Header().Add("Content-type", "application/json")
	w.Write(data)
}
开发者ID:cjnygard,项目名称:origin,代码行数:15,代码来源:server.go

示例6: List

func (storage *PodRegistryStorage) List(url *url.URL) (interface{}, error) {
	var result api.PodList
	var query *map[string]string
	if url != nil {
		queryMap := client.DecodeLabelQuery(url.Query().Get("labels"))
		query = &queryMap
	}
	pods, err := storage.registry.ListPods(query)
	if err == nil {
		result = api.PodList{
			Items: pods,
		}
	}
	result.Kind = "cluster#podList"
	return result, err
}
开发者ID:happywky,项目名称:kubernetes,代码行数:16,代码来源:pod_registry.go

示例7: ListPodsPredicate

// ListPodsPredicate obtains a list of pods that match filter.
func (r *Registry) ListPodsPredicate(ctx api.Context, filter func(*api.Pod) bool) (*api.PodList, error) {
	allPods := api.PodList{}
	key := makePodListKey(ctx)
	err := r.ExtractToList(key, &allPods)
	if err != nil {
		return nil, err
	}
	filtered := []api.Pod{}
	for _, pod := range allPods.Items {
		if filter(&pod) {
			filtered = append(filtered, pod)
		}
	}
	allPods.Items = filtered
	return &allPods, nil
}
开发者ID:hortonworks,项目名称:kubernetes-yarn,代码行数:17,代码来源:etcd.go

示例8: ListPods

// ListPods obtains a list of pods that match selector.
func (r *Registry) ListPods(selector labels.Selector) (*api.PodList, error) {
	allPods := api.PodList{}
	err := r.ExtractList("/registry/pods", &allPods.Items, &allPods.ResourceVersion)
	if err != nil {
		return nil, err
	}
	filtered := []api.Pod{}
	for _, pod := range allPods.Items {
		if selector.Matches(labels.Set(pod.Labels)) {
			// TODO: Currently nothing sets CurrentState.Host. We need a feedback loop that sets
			// the CurrentState.Host and Status fields. Here we pretend that reality perfectly
			// matches our desires.
			pod.CurrentState.Host = pod.DesiredState.Host
			filtered = append(filtered, pod)
		}
	}
	allPods.Items = filtered
	return &allPods, nil
}
开发者ID:nvdnkpr,项目名称:kubernetes,代码行数:20,代码来源:etcd.go

示例9: ListPodsPredicate

// ListPodsPredicate obtains a list of pods that match filter.
func (r *Registry) ListPodsPredicate(ctx api.Context, filter func(*api.Pod) bool) (*api.PodList, error) {
	allPods := api.PodList{}
	key := makePodListKey(ctx)
	err := r.ExtractToList(key, &allPods)
	if err != nil {
		return nil, err
	}
	filtered := []api.Pod{}
	for _, pod := range allPods.Items {
		if filter(&pod) {
			// TODO: Currently nothing sets CurrentState.Host. We need a feedback loop that sets
			// the CurrentState.Host and Status fields. Here we pretend that reality perfectly
			// matches our desires.
			pod.CurrentState.Host = pod.DesiredState.Host
			filtered = append(filtered, pod)
		}
	}
	allPods.Items = filtered
	return &allPods, nil
}
开发者ID:ericcapricorn,项目名称:kubernetes,代码行数:21,代码来源:etcd.go

示例10: List

func (storage *PodRegistryStorage) List(selector labels.Selector) (interface{}, error) {
	var result api.PodList
	pods, err := storage.registry.ListPods(selector)
	if err == nil {
		result.Items = pods
		// Get cached info for the list currently.
		// TODO: Optionally use fresh info
		if storage.podCache != nil {
			for ix, pod := range pods {
				info, err := storage.podCache.GetContainerInfo(pod.CurrentState.Host, pod.ID)
				if err != nil {
					glog.Errorf("Error getting container info: %#v", err)
					continue
				}
				result.Items[ix].CurrentState.Info = info
			}
		}
	}

	return result, err
}
开发者ID:jmoretti,项目名称:kubernetes,代码行数:21,代码来源:pod_registry.go


注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/api.PodList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。