本文整理汇总了Golang中k8s/io/client-go/pkg/apimachinery/registered.Group函数的典型用法代码示例。如果您正苦于以下问题:Golang Group函数的具体用法?Golang Group怎么用?Golang Group使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Group函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: checkNamespace
// checkNamespace makes sure that the scope of gvk matches ns. It
// returns an error if namespace is empty but gvk is a namespaced
// kind, or if ns is non-empty and gvk is a namespaced kind.
func checkNamespace(gvk schema.GroupVersionKind, ns string) error {
group, err := registered.Group(gvk.Group)
if err != nil {
return err
}
mapping, err := group.RESTMapper.RESTMapping(gvk.GroupKind(), gvk.Version)
if err != nil {
return err
}
switch mapping.Scope.Name() {
case meta.RESTScopeNameRoot:
if ns != "" {
return fmt.Errorf("namespace specified for a non-namespaced kind %s", gvk)
}
case meta.RESTScopeNameNamespace:
if ns == "" {
// Skipping this check for Events, since
// controllers emit events that have no namespace,
// even though Event is a namespaced resource.
if gvk.Kind != "Event" {
return fmt.Errorf("no namespace specified for a namespaced kind %s", gvk)
}
}
}
return nil
}
示例2: interfacesFor
// interfacesFor returns the default Codec and ResourceVersioner for a given version
// string, or an error if the version is not known.
func interfacesFor(version schema.GroupVersion) (*meta.VersionInterfaces, error) {
switch version {
case v1beta1.SchemeGroupVersion:
return &meta.VersionInterfaces{
ObjectConvertor: api.Scheme,
MetadataAccessor: accessor,
}, nil
default:
g, _ := registered.Group(federation.GroupName)
return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions)
}
}