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


Golang generic.MatcherFunc函数代码示例

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


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

示例1: NewREST

// NewREST returns a RESTStorage object that will work with testtype.
func NewREST(s storage.Interface, storageDecorator generic.StorageDecorator) *REST {
	prefix := "/testtype"
	newListFunc := func() runtime.Object { return &testgroup.TestTypeList{} }
	// Usually you should reuse your RESTCreateStrategy.
	strategy := &NotNamespaceScoped{}
	storageInterface := storageDecorator(
		s, 100, &testgroup.TestType{}, prefix, strategy, newListFunc)
	store := &etcdgeneric.Etcd{
		NewFunc: func() runtime.Object { return &testgroup.TestType{} },
		// NewListFunc returns an object capable of storing results of an etcd list.
		NewListFunc: newListFunc,
		// Produces a path that etcd understands, to the root of the resource
		// by combining the namespace in the context with the given prefix.
		KeyRootFunc: func(ctx api.Context) string {
			return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
		},
		// Produces a path that etcd understands, to the resource by combining
		// the namespace in the context with the given prefix.
		KeyFunc: func(ctx api.Context, name string) (string, error) {
			return etcdgeneric.NamespaceKeyFunc(ctx, prefix, name)
		},
		// Retrieve the name field of the resource.
		ObjectNameFunc: func(obj runtime.Object) (string, error) {
			return obj.(*testgroup.TestType).Name, nil
		},
		// Used to match objects based on labels/fields for list.
		PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
			return generic.MatcherFunc(nil)
		},
		Storage: storageInterface,
	}
	return &REST{store}
}
开发者ID:RomainVabre,项目名称:origin,代码行数:34,代码来源:reststorage.go

示例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) {
		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
	})
}
开发者ID:RomainVabre,项目名称:origin,代码行数:10,代码来源:strategy.go

示例3: 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
	})
}
开发者ID:RomainVabre,项目名称:origin,代码行数:10,代码来源:strategy.go

示例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) {
		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
	})
}
开发者ID:johnmccawley,项目名称:origin,代码行数:10,代码来源:strategy.go

示例5: MatchPodTemplate

// MatchPodTemplate returns a generic matcher for a given label and field selector.
func MatchPodTemplate(label labels.Selector, field fields.Selector) generic.Matcher {
	return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
		podObj, ok := obj.(*api.PodTemplate)
		if !ok {
			return false, fmt.Errorf("not a pod template")
		}
		return label.Matches(labels.Set(podObj.Labels)), nil
	})
}
开发者ID:MarWestermann,项目名称:gofabric8,代码行数:10,代码来源:rest.go

示例6: MatchAutoscaler

// MatchAutoscaler returns a generic matcher for a given label and field selector.
func MatchAutoscaler(label labels.Selector, field fields.Selector) generic.Matcher {
	return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
		autoscaler, ok := obj.(*expapi.HorizontalPodAutoscaler)
		if !ok {
			return false, fmt.Errorf("not a horizontal pod autoscaler")
		}
		return label.Matches(labels.Set(autoscaler.Labels)), nil
	})
}
开发者ID:ngbinh,项目名称:kubernetes,代码行数:10,代码来源:rest.go

示例7: MatchHostSubnet

// MatchHostSubnet returns a generic matcher for a given label and field selector.
func MatchHostSubnet(label labels.Selector, field fields.Selector) generic.Matcher {
	return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
		_, ok := obj.(*api.HostSubnet)
		if !ok {
			return false, fmt.Errorf("not a HostSubnet")
		}
		return true, nil
	})
}
开发者ID:jhadvig,项目名称:origin,代码行数:10,代码来源:strategy.go

示例8: MatchClusterNetwork

// MatchClusterNetwork returns a generic matcher for a given label and field selector.
func MatchClusterNetwork(label labels.Selector, field fields.Selector) generic.Matcher {
	return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
		_, ok := obj.(*api.ClusterNetwork)
		if !ok {
			return false, fmt.Errorf("not a ClusterNetwork")
		}
		return true, nil
	})
}
开发者ID:jhadvig,项目名称:origin,代码行数:10,代码来源:strategy.go

示例9: MatchNetNamespace

// MatchNetNamespace returns a generic matcher for a given label and field selector.
func MatchNetNamespace(label labels.Selector, field fields.Selector) generic.Matcher {
	return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
		_, ok := obj.(*api.NetNamespace)
		if !ok {
			return false, fmt.Errorf("not a NetNamespace")
		}
		return true, nil
	})
}
开发者ID:jhadvig,项目名称:origin,代码行数:10,代码来源:strategy.go

示例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
	})
}
开发者ID:johnmccawley,项目名称:origin,代码行数:11,代码来源:strategy.go

示例11: 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.ThirdPartyResourceData)
		if !ok {
			return false, fmt.Errorf("not a ThirdPartyResourceData")
		}
		fields := SelectableFields(sa)
		return label.Matches(labels.Set(sa.Labels)) && field.Matches(fields), nil
	})
}
开发者ID:40a,项目名称:bootkube,代码行数:11,代码来源:strategy.go

示例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
	})
}
开发者ID:abursavich,项目名称:kubernetes,代码行数:11,代码来源:strategy.go

示例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
	})
}
开发者ID:jhadvig,项目名称:origin,代码行数:11,代码来源:strategy.go

示例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
	})
}
开发者ID:johnmccawley,项目名称:origin,代码行数:11,代码来源:strategy.go

示例15: 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
	})
}
开发者ID:Xmagicer,项目名称:origin,代码行数:11,代码来源:strategy.go


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