Use groupName comment for listers/informers

If present, use the "// +groupName" doc comment as the desired group
name when generating listers and informers.
This commit is contained in:
Andy Goldstein 2017-05-01 11:58:26 -04:00
parent 6ae80a6261
commit a5761d8074
2 changed files with 14 additions and 0 deletions

View File

@ -150,6 +150,13 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
targetGroupVersions = externalGroupVersions
}
// If there's a comment of the form "// +groupName=somegroup" or
// "// +groupName=somegroup.foo.bar.io", use the first field (somegroup) as the name of the
// group when generating.
if override := types.ExtractCommentTags("+", p.DocComments)["groupName"]; override != nil {
gv.Group = clientgentypes.Group(strings.SplitN(override[0], ".", 2)[0])
}
var typesToGenerate []*types.Type
for _, t := range p.Types {
// filter out types which dont have genclient=true.

View File

@ -106,6 +106,13 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
internalGVPkg = strings.Join(parts[0:len(parts)-1], "/")
}
// If there's a comment of the form "// +groupName=somegroup" or
// "// +groupName=somegroup.foo.bar.io", use the first field (somegroup) as the name of the
// group when generating.
if override := types.ExtractCommentTags("+", p.DocComments)["groupName"]; override != nil {
gv.Group = clientgentypes.Group(strings.SplitN(override[0], ".", 2)[0])
}
var typesToGenerate []*types.Type
for _, t := range p.Types {
// filter out types which dont have genclient=true.