本文整理匯總了Golang中k8s/io/kubernetes/pkg/fields.Selector.RequiresExactMatch方法的典型用法代碼示例。如果您正苦於以下問題:Golang Selector.RequiresExactMatch方法的具體用法?Golang Selector.RequiresExactMatch怎麽用?Golang Selector.RequiresExactMatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/fields.Selector
的用法示例。
在下文中一共展示了Selector.RequiresExactMatch方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: WatchServices
// WatchServices begins watching for new, changed, or deleted service configurations.
func (r *Registry) WatchServices(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
version, err := storage.ParseWatchResourceVersion(resourceVersion, "service")
if err != nil {
return nil, err
}
if !label.Empty() {
return nil, fmt.Errorf("label selectors are not supported on services")
}
if value, found := field.RequiresExactMatch("name"); found {
key, err := makeServiceKey(ctx, value)
if err != nil {
return nil, err
}
// TODO: use generic.SelectionPredicate
return r.Watch(key, version, storage.Everything)
}
if field.Empty() {
return r.WatchList(makeServiceListKey(ctx), version, storage.Everything)
}
return nil, fmt.Errorf("only the 'name' and default (everything) field selectors are supported")
}
示例2: WatchRoutes
// WatchRoutes begins watching for new, changed, or deleted route configurations.
func (registry *Etcd) WatchRoutes(ctx kapi.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
if !label.Empty() {
return nil, fmt.Errorf("label selectors are not supported on routes yet")
}
version, err := storage.ParseWatchResourceVersion(resourceVersion, "pod")
if err != nil {
return nil, err
}
if value, found := field.RequiresExactMatch("ID"); found {
key, err := makeRouteKey(ctx, value)
if err != nil {
return nil, err
}
return registry.Watch(key, version, storage.Everything)
}
if field.Empty() {
key := kubeetcd.MakeEtcdListKey(ctx, RoutePath)
return registry.WatchList(key, version, storage.Everything)
}
return nil, fmt.Errorf("only the 'ID' and default (everything) field selectors are supported")
}