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


Golang GroupVersionResource.Resource方法代码示例

本文整理汇总了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
}
开发者ID:kubernetes,项目名称:kubernetes,代码行数:34,代码来源:shortcut_restmapper.go

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


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