本文整理汇总了Golang中k8s/io/apimachinery/pkg/runtime/schema.GroupVersionResource.Resource方法的典型用法代码示例。如果您正苦于以下问题:Golang GroupVersionResource.Resource方法的具体用法?Golang GroupVersionResource.Resource怎么用?Golang GroupVersionResource.Resource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/apimachinery/pkg/runtime/schema.GroupVersionResource
的用法示例。
在下文中一共展示了GroupVersionResource.Resource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: expandResourceShortcut
// expandResourceShortcut will return the expanded version of resource
// (something that a pkg/api/meta.RESTMapper can understand), if it is
// indeed a shortcut. If no match has been found, we will match on group prefixing.
// Lastly we will return resource unmodified.
func (e ShortcutExpander) expandResourceShortcut(resource schema.GroupVersionResource) schema.GroupVersionResource {
// get the shortcut mappings and return on first match.
if resources, err := e.getShortcutMappings(); err == nil {
for _, item := range resources {
if len(resource.Group) != 0 && resource.Group != item.ShortForm.Group {
continue
}
if resource.Resource == item.ShortForm.Resource {
resource.Resource = item.LongForm.Resource
return resource
}
}
// we didn't find exact match so match on group prefixing. This allows autoscal to match autoscaling
if len(resource.Group) == 0 {
return resource
}
for _, item := range resources {
if !strings.HasPrefix(item.ShortForm.Group, resource.Group) {
continue
}
if resource.Resource == item.ShortForm.Resource {
resource.Resource = item.LongForm.Resource
return resource
}
}
}
return resource
}
示例2: coerceResourceForMatching
// coerceResourceForMatching makes the resource lower case and converts internal versions to unspecified (legacy behavior)
func coerceResourceForMatching(resource schema.GroupVersionResource) schema.GroupVersionResource {
resource.Resource = strings.ToLower(resource.Resource)
if resource.Version == runtime.APIVersionInternal {
resource.Version = ""
}
return resource
}