mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
make client-gen behave correctly when there is no types in a group that
needs client.
This commit is contained in:
parent
6b97376a53
commit
b9ab758081
@ -40,13 +40,19 @@ type genFakeForGroup struct {
|
|||||||
// types in this group
|
// types in this group
|
||||||
types []*types.Type
|
types []*types.Type
|
||||||
imports namer.ImportTracker
|
imports namer.ImportTracker
|
||||||
|
// If the genGroup has been called. This generator should only execute once.
|
||||||
|
called bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ generator.Generator = &genFakeForGroup{}
|
var _ generator.Generator = &genFakeForGroup{}
|
||||||
|
|
||||||
// We only want to call GenerateType() once per group.
|
// We only want to call GenerateType() once per group.
|
||||||
func (g *genFakeForGroup) Filter(c *generator.Context, t *types.Type) bool {
|
func (g *genFakeForGroup) Filter(c *generator.Context, t *types.Type) bool {
|
||||||
return len(g.types) == 0 || t == g.types[0]
|
if !g.called {
|
||||||
|
g.called = true
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *genFakeForGroup) Namers(c *generator.Context) namer.NameSystems {
|
func (g *genFakeForGroup) Namers(c *generator.Context) namer.NameSystems {
|
||||||
@ -56,7 +62,10 @@ func (g *genFakeForGroup) Namers(c *generator.Context) namer.NameSystems {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *genFakeForGroup) Imports(c *generator.Context) (imports []string) {
|
func (g *genFakeForGroup) Imports(c *generator.Context) (imports []string) {
|
||||||
imports = append(g.imports.ImportLines(), strings.ToLower(fmt.Sprintf("%s \"%s\"", filepath.Base(g.realClientPackage), g.realClientPackage)))
|
imports = g.imports.ImportLines()
|
||||||
|
if len(g.types) != 0 {
|
||||||
|
imports = append(imports, strings.ToLower(fmt.Sprintf("%s \"%s\"", filepath.Base(g.realClientPackage), g.realClientPackage)))
|
||||||
|
}
|
||||||
return imports
|
return imports
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,13 +41,19 @@ type genGroup struct {
|
|||||||
imports namer.ImportTracker
|
imports namer.ImportTracker
|
||||||
inputPackage string
|
inputPackage string
|
||||||
clientsetPackage string
|
clientsetPackage string
|
||||||
|
// If the genGroup has been called. This generator should only execute once.
|
||||||
|
called bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ generator.Generator = &genGroup{}
|
var _ generator.Generator = &genGroup{}
|
||||||
|
|
||||||
// We only want to call GenerateType() once per group.
|
// We only want to call GenerateType() once per group.
|
||||||
func (g *genGroup) Filter(c *generator.Context, t *types.Type) bool {
|
func (g *genGroup) Filter(c *generator.Context, t *types.Type) bool {
|
||||||
return len(g.types) == 0 || t == g.types[0]
|
if !g.called {
|
||||||
|
g.called = true
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *genGroup) Namers(c *generator.Context) namer.NameSystems {
|
func (g *genGroup) Namers(c *generator.Context) namer.NameSystems {
|
||||||
|
Loading…
Reference in New Issue
Block a user