Example #1
0
// 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
	})
}
Example #2
0
// 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) {
		subnet, ok := obj.(*api.HostSubnet)
		if !ok {
			return false, fmt.Errorf("not a HostSubnet")
		}
		return label.Matches(labels.Set(subnet.Labels)) && field.Matches(api.HostSubnetToSelectableFields(subnet)), nil
	})
}
Example #3
0
// 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
	})
}
Example #4
0
// 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
	})
}
Example #5
0
// 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
	})
}
Example #6
0
// 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
	})
}
Example #7
0
// 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
	})
}
Example #8
0
// 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
	})
}
Example #9
0
// 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
	})
}
Example #10
0
// 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
	})
}
Example #11
0
// 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
	})
}
Example #12
0
// 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) {
		network, ok := obj.(*api.ClusterNetwork)
		if !ok {
			return false, fmt.Errorf("not a ClusterNetwork")
		}
		fields := api.ClusterNetworkToSelectableFields(network)
		return label.Matches(labels.Set(network.Labels)) && field.Matches(fields), nil
	})
}
Example #13
0
// 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
	})
}
Example #14
0
// 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
	})
}
Example #15
0
// 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
	})
}
Example #16
0
// 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
	})
}
Example #17
0
// 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
	})
}
Example #18
0
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
}
Example #19
0
func (m *VirtualStorage) List(ctx kapi.Context, label labels.Selector, field fields.Selector) (runtime.Object, error) {
	policyList, err := m.PolicyStorage.ListPolicies(ctx, labels.Everything(), fields.Everything())
	if err != nil {
		return nil, err
	}

	roleList := &authorizationapi.RoleList{}

	for _, policy := range policyList.Items {
		for _, role := range policy.Roles {
			if label.Matches(labels.Set(role.Labels)) && field.Matches(authorizationapi.RoleToSelectableFields(role)) {
				roleList.Items = append(roleList.Items, *role)
			}
		}
	}

	return roleList, nil
}
Example #20
0
// 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.(*certificates.CertificateSigningRequest)
		if !ok {
			return false, fmt.Errorf("not a CertificateSigningRequest")
		}
		fields := SelectableFields(sa)
		return label.Matches(labels.Set(sa.Labels)) && field.Matches(fields), nil
	})
}
Example #21
0
func (c *readOnlyPolicyBindingCache) List(label labels.Selector, field fields.Selector, namespace string) (*authorizationapi.PolicyBindingList, error) {
	var returnedList []interface{}
	if namespace == kapi.NamespaceAll {
		returnedList = c.indexer.List()
	} else {
		items, err := c.indexer.Index("namespace", &authorizationapi.PolicyBinding{ObjectMeta: kapi.ObjectMeta{Namespace: namespace}})
		returnedList = items
		if err != nil {
			return &authorizationapi.PolicyBindingList{}, errors.NewInvalid("PolicyBindingList", "policyBindingList", []error{err})
		}
	}
	policyBindingList := &authorizationapi.PolicyBindingList{}
	for i := range returnedList {
		policyBinding, castOK := returnedList[i].(*authorizationapi.PolicyBinding)
		if !castOK {
			return policyBindingList, errors.NewInvalid("PolicyBindingList", "policyBindingList", []error{})
		}
		if label.Matches(labels.Set(policyBinding.Labels)) && field.Matches(PolicyBindingToSelectableFields(policyBinding)) {
			policyBindingList.Items = append(policyBindingList.Items, *policyBinding)
		}
	}
	return policyBindingList, nil
}