本文整理汇总了Golang中k8s/io/kubernetes/pkg/labels.Set.AsSelector方法的典型用法代码示例。如果您正苦于以下问题:Golang Set.AsSelector方法的具体用法?Golang Set.AsSelector怎么用?Golang Set.AsSelector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/labels.Set
的用法示例。
在下文中一共展示了Set.AsSelector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Query
// Query fetches all releases that match the provided map of labels.
// An error is returned if the configmap fails to retrieve the releases.
func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, error) {
ls := kblabels.Set{}
for k, v := range labels {
ls[k] = v
}
opts := api.ListOptions{LabelSelector: ls.AsSelector()}
list, err := cfgmaps.impl.List(opts)
if err != nil {
logerrf(err, "query: failed to query with labels")
return nil, err
}
if len(list.Items) == 0 {
return nil, ErrReleaseNotFound
}
var results []*rspb.Release
for _, item := range list.Items {
rls, err := decodeRelease(item.Data["release"])
if err != nil {
logerrf(err, "query: failed to decode release: %s", err)
continue
}
results = append(results, rls)
}
return results, nil
}
示例2: printDebugInfo
func printDebugInfo(c *client.Client) {
set := labels.Set{"k8s-app": "heapster"}
options := api.ListOptions{LabelSelector: set.AsSelector()}
podList, err := c.Pods(api.NamespaceSystem).List(options)
if err != nil {
Logf("Error while listing pods %v", err)
return
}
for _, pod := range podList.Items {
Logf("Kubectl output:\n%v", runKubectlOrDie("log", pod.Name, "--namespace=kube-system"))
}
}
示例3: printDebugInfo
func printDebugInfo(c clientset.Interface) {
set := labels.Set{"k8s-app": "heapster"}
options := api.ListOptions{LabelSelector: set.AsSelector()}
podList, err := c.Core().Pods(api.NamespaceSystem).List(options)
if err != nil {
framework.Logf("Error while listing pods %v", err)
return
}
for _, pod := range podList.Items {
framework.Logf("Kubectl output:\n%v",
framework.RunKubectlOrDie("log", pod.Name, "--namespace=kube-system", "--container=heapster"))
}
}