本文整理汇总了Golang中k8s/io/kubernetes/pkg/api/unversioned.ParseResourceArg函数的典型用法代码示例。如果您正苦于以下问题:Golang ParseResourceArg函数的具体用法?Golang ParseResourceArg怎么用?Golang ParseResourceArg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ParseResourceArg函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: RunExplain
// RunExplain executes the appropriate steps to print a model's documentation
func RunExplain(f *cmdutil.Factory, out, cmdErr io.Writer, cmd *cobra.Command, args []string) error {
if len(args) == 0 {
fmt.Fprint(cmdErr, "You must specify the type of resource to explain. ", valid_resources)
return cmdutil.UsageError(cmd, "Required resource not specified.")
}
if len(args) > 1 {
return cmdutil.UsageError(cmd, "We accept only this format: explain RESOURCE")
}
recursive := cmdutil.GetFlagBool(cmd, "recursive")
apiVersionString := cmdutil.GetFlagString(cmd, "api-version")
apiVersion := unversioned.GroupVersion{}
mapper, _ := f.Object(cmdutil.GetIncludeThirdPartyAPIs(cmd))
// TODO: After we figured out the new syntax to separate group and resource, allow
// the users to use it in explain (kubectl explain <group><syntax><resource>).
// Refer to issue #16039 for why we do this. Refer to PR #15808 that used "/" syntax.
inModel, fieldsPath, err := kubectl.SplitAndParseResourceRequest(args[0], mapper)
if err != nil {
return err
}
// TODO: We should deduce the group for a resource by discovering the supported resources at server.
fullySpecifiedGVR, groupResource := unversioned.ParseResourceArg(inModel)
gvk := unversioned.GroupVersionKind{}
if fullySpecifiedGVR != nil {
gvk, _ = mapper.KindFor(*fullySpecifiedGVR)
}
if gvk.Empty() {
gvk, err = mapper.KindFor(groupResource.WithVersion(""))
if err != nil {
return err
}
}
if len(apiVersionString) == 0 {
groupMeta, err := registered.Group(gvk.Group)
if err != nil {
return err
}
apiVersion = groupMeta.GroupVersion
} else {
apiVersion, err = unversioned.ParseGroupVersion(apiVersionString)
if err != nil {
return nil
}
}
schema, err := f.SwaggerSchema(apiVersion.WithKind(gvk.Kind))
if err != nil {
return err
}
return kubectl.PrintModelDescription(inModel, fieldsPath, out, schema, recursive)
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:57,代码来源:explain.go
示例2: mappingFor
// mappingFor returns the RESTMapping for the Kind referenced by the resource.
// prefers a fully specified GroupVersionResource match. If we don't have one match on GroupResource
func (b *Builder) mappingFor(resourceArg string) (*meta.RESTMapping, error) {
fullySpecifiedGVR, groupResource := unversioned.ParseResourceArg(resourceArg)
gvk := unversioned.GroupVersionKind{}
if fullySpecifiedGVR != nil {
gvk, _ = b.mapper.KindFor(*fullySpecifiedGVR)
}
if gvk.Empty() {
var err error
gvk, err = b.mapper.KindFor(groupResource.WithVersion(""))
if err != nil {
return nil, err
}
}
return b.mapper.RESTMapping(gvk.GroupKind(), gvk.Version)
}
开发者ID:eljefedelrodeodeljefe,项目名称:kubernetes,代码行数:18,代码来源:builder.go
示例3: resourceFor
func resourceFor(mapper meta.RESTMapper, resourceArg string) unversioned.GroupVersionResource {
fullySpecifiedGVR, groupResource := unversioned.ParseResourceArg(strings.ToLower(resourceArg))
gvr := unversioned.GroupVersionResource{}
if fullySpecifiedGVR != nil {
gvr, _ = mapper.ResourceFor(*fullySpecifiedGVR)
}
if gvr.IsEmpty() {
var err error
gvr, err = mapper.ResourceFor(groupResource.WithVersion(""))
if err != nil {
return unversioned.GroupVersionResource{Resource: resourceArg}
}
}
return gvr
}
开发者ID:Xmagicer,项目名称:origin,代码行数:16,代码来源:who_can.go
注:本文中的k8s/io/kubernetes/pkg/api/unversioned.ParseResourceArg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论