本文整理汇总了Golang中k8s/io/kubernetes/pkg/fields.Selector类的典型用法代码示例。如果您正苦于以下问题:Golang Selector类的具体用法?Golang Selector怎么用?Golang Selector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Selector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Matcher
// Matcher returns a generic matcher for a given label and field selector.
func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
ns, ok := obj.(*api.NetNamespace)
if !ok {
return false, fmt.Errorf("not a NetNamespace")
}
return label.Matches(labels.Set(ns.Labels)) && field.Matches(api.NetNamespaceToSelectableFields(ns)), nil
})
}
示例2: Matcher
// Matcher returns a generic matcher for a given label and field selector.
func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
o, ok := obj.(*api.Template)
if !ok {
return false, fmt.Errorf("not a pod")
}
return label.Matches(labels.Set(o.Labels)) && field.Matches(api.TemplateToSelectableFields(o)), nil
})
}
示例3: MatchUser
// MatchUser returns a generic matcher for a given label and field selector.
func MatchUser(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
userObj, ok := obj.(*api.User)
if !ok {
return false, fmt.Errorf("not a user")
}
fields := UserToSelectableFields(userObj)
return label.Matches(labels.Set(userObj.Labels)) && field.Matches(fields), nil
})
}
示例4: MatchTenant
// MatchTenant returns a generic matcher for a given label and field selector.
func MatchTenant(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
tenantObj, ok := obj.(*api.Tenant)
if !ok {
return false, fmt.Errorf("not a tenant")
}
fields := TenantToSelectableFields(tenantObj)
return label.Matches(labels.Set(tenantObj.Labels)) && field.Matches(fields), nil
})
}
示例5: Matcher
// Matchtoken returns a generic matcher for a given label and field selector.
func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
tokenObj, ok := obj.(*api.OAuthAuthorizeToken)
if !ok {
return false, fmt.Errorf("not a token")
}
fields := api.OAuthAuthorizeTokenToSelectableFields(tokenObj)
return label.Matches(labels.Set(tokenObj.Labels)) && field.Matches(fields), nil
})
}
示例6: ListControllers
// List obtains a list of ReplicationControllers that match selector.
func (s *storage) ListControllers(ctx api.Context, label labels.Selector, field fields.Selector) (*api.ReplicationControllerList, error) {
if !field.Empty() {
return nil, fmt.Errorf("field selector not supported yet")
}
obj, err := s.List(ctx, label, field)
if err != nil {
return nil, err
}
return obj.(*api.ReplicationControllerList), err
}
示例7: MatchGroup
// MatchGroup returns a generic matcher for a given label and field selector.
func MatchGroup(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
groupObj, ok := obj.(*api.Group)
if !ok {
return false, fmt.Errorf("not a group")
}
fields := GroupToSelectableFields(groupObj)
return label.Matches(labels.Set(groupObj.Labels)) && field.Matches(fields), nil
})
}
示例8: Matcher
// Matcher returns a generic matcher for a given label and field selector.
func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
sa, ok := obj.(*api.Secret)
if !ok {
return false, fmt.Errorf("not a secret")
}
fields := SelectableFields(sa)
return label.Matches(labels.Set(sa.Labels)) && field.Matches(fields), nil
})
}
示例9: Matcher
// Matchtoken returns a generic matcher for a given label and field selector.
func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
clientObj, ok := obj.(*api.OAuthClient)
if !ok {
return false, fmt.Errorf("not a client")
}
fields := SelectableFields(clientObj)
return label.Matches(labels.Set(clientObj.Labels)) && field.Matches(fields), nil
})
}
示例10: MatchNamespace
// MatchNamespace returns a generic matcher for a given label and field selector.
func MatchNamespace(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
namespaceObj, ok := obj.(*api.Namespace)
if !ok {
return false, fmt.Errorf("not a namespace")
}
fields := NamespaceToSelectableFields(namespaceObj)
return label.Matches(labels.Set(namespaceObj.Labels)) && field.Matches(fields), nil
})
}
示例11: ListDeployments
// List obtains a list of Deployments that match selector.
func (s *storage) ListDeployments(ctx api.Context, label labels.Selector, field fields.Selector) (*experimental.DeploymentList, error) {
if !field.Empty() {
return nil, fmt.Errorf("field selector not supported yet")
}
obj, err := s.List(ctx, label, field)
if err != nil {
return nil, err
}
return obj.(*experimental.DeploymentList), err
}
示例12: MatchResourceQuota
// MatchResourceQuota returns a generic matcher for a given label and field selector.
func MatchResourceQuota(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
resourcequotaObj, ok := obj.(*api.ResourceQuota)
if !ok {
return false, fmt.Errorf("not a resourcequota")
}
fields := ResourceQuotaToSelectableFields(resourcequotaObj)
return label.Matches(labels.Set(resourcequotaObj.Labels)) && field.Matches(fields), nil
})
}
示例13: MatchImageStream
// MatchImageStream returns a generic matcher for a given label and field selector.
func MatchImageStream(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
ir, ok := obj.(*api.ImageStream)
if !ok {
return false, fmt.Errorf("not an ImageStream")
}
fields := ImageStreamToSelectableFields(ir)
return label.Matches(labels.Set(ir.Labels)) && field.Matches(fields), nil
})
}
示例14: ListJobs
func (s *storage) ListJobs(ctx api.Context, label labels.Selector, field fields.Selector) (*extensions.JobList, error) {
if !field.Empty() {
return nil, fmt.Errorf("field selector not supported yet")
}
obj, err := s.List(ctx, label, field)
if err != nil {
return nil, err
}
return obj.(*extensions.JobList), err
}
示例15: Matcher
// Matcher returns a generic matcher for a given label and field selector.
func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
scc, ok := obj.(*api.SecurityContextConstraints)
if !ok {
return false, fmt.Errorf("not a securitycontextconstraint")
}
fields := SelectableFields(scc)
return label.Matches(labels.Set(scc.Labels)) && field.Matches(fields), nil
})
}