當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Selector.RequiresExactMatch方法代碼示例

本文整理匯總了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/labels.Selector.RequiresExactMatch方法的典型用法代碼示例。如果您正苦於以下問題:Golang Selector.RequiresExactMatch方法的具體用法?Golang Selector.RequiresExactMatch怎麽用?Golang Selector.RequiresExactMatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/GoogleCloudPlatform/kubernetes/pkg/labels.Selector的用法示例。


在下文中一共展示了Selector.RequiresExactMatch方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: WatchEndpoints

// WatchEndpoints begins watching for new, changed, or deleted endpoint configurations.
func (r *Registry) WatchEndpoints(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
	if !label.Empty() {
		return nil, fmt.Errorf("label selectors are not supported on endpoints")
	}
	if value, found := field.RequiresExactMatch("ID"); found {
		return r.Watch(makeServiceEndpointsKey(value), resourceVersion)
	}
	if field.Empty() {
		return r.WatchList("/registry/services/endpoints", resourceVersion, tools.Everything)
	}
	return nil, fmt.Errorf("only the 'ID' and default (everything) field selectors are supported")
}
開發者ID:nvdnkpr,項目名稱:kubernetes,代碼行數:13,代碼來源:etcd.go

示例2: WatchEndpoints

// WatchEndpoints begins watching for new, changed, or deleted endpoint configurations.
func (r *Registry) WatchEndpoints(ctx api.Context, label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
	version, err := tools.ParseWatchResourceVersion(resourceVersion, "endpoints")
	if err != nil {
		return nil, err
	}
	if !label.Empty() {
		return nil, fmt.Errorf("label selectors are not supported on endpoints")
	}
	if value, found := field.RequiresExactMatch("name"); found {
		key, err := makeServiceEndpointsKey(ctx, value)
		if err != nil {
			return nil, err
		}
		return r.Watch(key, version), nil
	}
	if field.Empty() {
		return r.WatchList(makeServiceEndpointsListKey(ctx), version, tools.Everything)
	}
	return nil, fmt.Errorf("only the 'ID' and default (everything) field selectors are supported")
}
開發者ID:hortonworks,項目名稱:kubernetes-yarn,代碼行數:21,代碼來源:etcd.go


注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/labels.Selector.RequiresExactMatch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。