upgrade controller-tools to v0.4.1

Signed-off-by: yuswift <yuswift2018@gmail.com>
This commit is contained in:
yuswift
2021-04-12 16:31:10 +08:00
parent adef4b5e43
commit 644a08aff3
28 changed files with 1817 additions and 147 deletions

View File

@@ -58,6 +58,14 @@ type Generator struct {
Year string `marker:",optional"`
}
func (Generator) CheckFilter() loader.NodeFilter {
return func(node ast.Node) bool {
// ignore interfaces
_, isIface := node.(*ast.InterfaceType)
return !isIface
}
}
func (Generator) RegisterMarkers(into *markers.Registry) error {
if err := markers.RegisterAll(into,
enablePkgMarker, legacyEnablePkgMarker, enableTypeMarker,
@@ -144,7 +152,7 @@ func (d Generator) Generate(ctx *genall.GenerationContext) error {
}
for _, root := range ctx.Roots {
outContents := objGenCtx.GenerateForPackage(root)
outContents := objGenCtx.generateForPackage(root)
if outContents == nil {
continue
}
@@ -186,21 +194,17 @@ import (
}
// GenerateForPackage generates DeepCopy and runtime.Object implementations for
// generateForPackage generates DeepCopy and runtime.Object implementations for
// types in the given package, writing the formatted result to given writer.
// May return nil if source could not be generated.
func (ctx *ObjectGenCtx) GenerateForPackage(root *loader.Package) []byte {
func (ctx *ObjectGenCtx) generateForPackage(root *loader.Package) []byte {
allTypes, err := enabledOnPackage(ctx.Collector, root)
if err != nil {
root.AddError(err)
return nil
}
ctx.Checker.Check(root, func(node ast.Node) bool {
// ignore interfaces
_, isIface := node.(*ast.InterfaceType)
return !isIface
})
ctx.Checker.Check(root)
root.NeedTypesInfo()