本文整理汇总了Golang中k8s/io/kubernetes/cmd/libs/go2idl/client-gen/generators/normalization.Version函数的典型用法代码示例。如果您正苦于以下问题:Golang Version函数的具体用法?Golang Version怎么用?Golang Version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Version函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GenerateType
func (g *genClientset) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
// TODO: We actually don't need any type information to generate the clientset,
// perhaps we can adapt the go2ild framework to this kind of usage.
sw := generator.NewSnippetWriter(w, c, "$", "$")
sw.Do(common, nil)
sw.Do(checkImpl, nil)
type arg struct {
Group string
PackageName string
}
allGroups := []arg{}
for _, gv := range g.groupVersions {
group := normalization.Group(gv.Group)
version := normalization.Version(gv.Version)
allGroups = append(allGroups, arg{namer.IC(group), version + group})
}
for _, g := range allGroups {
sw.Do(clientsetInterfaceImplTemplate, g)
}
return sw.Error()
}
示例2: Imports
func (g *genClientset) Imports(c *generator.Context) (imports []string) {
imports = append(imports, g.imports.ImportLines()...)
for _, gv := range g.groupVersions {
group := normalization.Group(gv.Group)
version := normalization.Version(gv.Version)
typedClientPath := filepath.Join(g.typedClientPath, group, version)
imports = append(imports, fmt.Sprintf("%s%s \"%s\"", version, group, typedClientPath))
fakeTypedClientPath := filepath.Join(typedClientPath, "fake")
imports = append(imports, fmt.Sprintf("fake%s%s \"%s\"", version, group, fakeTypedClientPath))
}
// the package that has the clientset Interface
imports = append(imports, fmt.Sprintf("clientset \"%s\"", g.clientsetPath))
// imports for the code in commonTemplate
imports = append(imports,
"k8s.io/kubernetes/pkg/api",
"k8s.io/kubernetes/pkg/apimachinery/registered",
"k8s.io/kubernetes/pkg/client/testing/core",
"k8s.io/kubernetes/pkg/client/typed/discovery",
"fakediscovery \"k8s.io/kubernetes/pkg/client/typed/discovery/fake\"",
"k8s.io/kubernetes/pkg/runtime",
"k8s.io/kubernetes/pkg/watch",
)
return
}
示例3: Imports
func (g *genClientset) Imports(c *generator.Context) (imports []string) {
imports = append(imports, g.imports.ImportLines()...)
for _, gv := range g.groupVersions {
group := normalization.Group(gv.Group)
version := normalization.Version(gv.Version)
typedClientPath := filepath.Join(g.typedClientPath, group, version)
imports = append(imports, fmt.Sprintf("%s_%s \"%s\"", group, version, typedClientPath))
}
return
}
示例4: Imports
func (g *genClientset) Imports(c *generator.Context) (imports []string) {
imports = append(imports, g.imports.ImportLines()...)
for _, gv := range g.groupVersions {
group := normalization.Group(gv.Group)
version := normalization.Version(gv.Version)
typedClientPath := filepath.Join(g.typedClientPath, group, version)
group = normalization.BeforeFirstDot(group)
imports = append(imports, fmt.Sprintf("%s%s \"%s\"", version, group, typedClientPath))
imports = append(imports, "github.com/golang/glog")
}
return
}
示例5: GenerateType
func (g *genClientset) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
// TODO: We actually don't need any type information to generate the clientset,
// perhaps we can adapt the go2ild framework to this kind of usage.
sw := generator.NewSnippetWriter(w, c, "$", "$")
const pkgDiscovery = "k8s.io/kubernetes/pkg/client/typed/discovery"
const pkgRESTClient = "k8s.io/kubernetes/pkg/client/restclient"
type arg struct {
Group string
PackageName string
}
allGroups := []arg{}
for _, gv := range g.groupVersions {
group := normalization.BeforeFirstDot(normalization.Group(gv.Group))
version := normalization.Version(gv.Version)
allGroups = append(allGroups, arg{namer.IC(group), version + group})
}
m := map[string]interface{}{
"allGroups": allGroups,
"Config": c.Universe.Type(types.Name{Package: pkgRESTClient, Name: "Config"}),
"DefaultKubernetesUserAgent": c.Universe.Function(types.Name{Package: pkgRESTClient, Name: "DefaultKubernetesUserAgent"}),
"RESTClient": c.Universe.Type(types.Name{Package: pkgRESTClient, Name: "RESTClient"}),
"DiscoveryInterface": c.Universe.Type(types.Name{Package: pkgDiscovery, Name: "DiscoveryInterface"}),
"DiscoveryClient": c.Universe.Type(types.Name{Package: pkgDiscovery, Name: "DiscoveryClient"}),
"NewDiscoveryClientForConfig": c.Universe.Function(types.Name{Package: pkgDiscovery, Name: "NewDiscoveryClientForConfig"}),
"NewDiscoveryClientForConfigOrDie": c.Universe.Function(types.Name{Package: pkgDiscovery, Name: "NewDiscoveryClientForConfigOrDie"}),
"NewDiscoveryClient": c.Universe.Function(types.Name{Package: pkgDiscovery, Name: "NewDiscoveryClient"}),
}
sw.Do(clientsetInterfaceTemplate, m)
sw.Do(clientsetTemplate, m)
for _, g := range allGroups {
sw.Do(clientsetInterfaceImplTemplate, g)
}
sw.Do(getDiscoveryTemplate, m)
sw.Do(newClientsetForConfigTemplate, m)
sw.Do(newClientsetForConfigOrDieTemplate, m)
sw.Do(newClientsetForRESTClientTemplate, m)
return sw.Error()
}