本文整理汇总了Golang中k8s/io/kubernetes/pkg/fields.Selector.Matches方法的典型用法代码示例。如果您正苦于以下问题:Golang Selector.Matches方法的具体用法?Golang Selector.Matches怎么用?Golang Selector.Matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/fields.Selector
的用法示例。
在下文中一共展示了Selector.Matches方法的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: 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
})
}
示例4: 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
})
}
示例5: 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
})
}
示例6: 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
})
}
示例7: 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
})
}
示例8: 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
})
}
示例9: 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.(*extensions.ThirdPartyResource)
if !ok {
return false, fmt.Errorf("not a ThirdPartyResource")
}
fields := SelectableFields(sa)
return label.Matches(labels.Set(sa.Labels)) && field.Matches(fields), nil
})
}
示例10: 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
})
}
示例11: 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
})
}
示例12: 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) {
identityObj, ok := obj.(*api.Identity)
if !ok {
return false, fmt.Errorf("not an identity")
}
fields := api.IdentityToSelectableFields(identityObj)
return label.Matches(labels.Set(identityObj.Labels)) && field.Matches(fields), nil
})
}
示例13: 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
})
}
示例14: MatchPersistentVolumes
// MatchPersistentVolume returns a generic matcher for a given label and field selector.
func MatchPersistentVolumes(label labels.Selector, field fields.Selector) generic.Matcher {
return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
persistentvolumeObj, ok := obj.(*api.PersistentVolume)
if !ok {
return false, fmt.Errorf("not a persistentvolume")
}
fields := PersistentVolumeToSelectableFields(persistentvolumeObj)
return label.Matches(labels.Set(persistentvolumeObj.Labels)) && field.Matches(fields), nil
})
}
示例15: List
func (c *readOnlyClusterPolicyBindingCache) List(label labels.Selector, field fields.Selector) (*authorizationapi.ClusterPolicyBindingList, error) {
clusterPolicyBindingList := &authorizationapi.ClusterPolicyBindingList{}
returnedList := c.indexer.List()
for i := range returnedList {
clusterPolicyBinding, castOK := returnedList[i].(*authorizationapi.ClusterPolicyBinding)
if !castOK {
return clusterPolicyBindingList, errors.NewInvalid("ClusterPolicyBinding", "clusterPolicyBinding", []error{})
}
if label.Matches(labels.Set(clusterPolicyBinding.Labels)) && field.Matches(ClusterPolicyBindingToSelectableFields(clusterPolicyBinding)) {
clusterPolicyBindingList.Items = append(clusterPolicyBindingList.Items, *clusterPolicyBinding)
}
}
return clusterPolicyBindingList, nil
}