-
Notifications
You must be signed in to change notification settings - Fork 461
Closed
crossplane-contrib/provider-gcp
#470Description
As an example (this is where I encountered the error), when running controller-gen against code which imports golang.org/x/sys/unix, it panics when trying to parse the following struct:
Specifically, the composite literal expression in this field:
_ [len(ifreq{}.Ifru) - SizeofPtr]byte
^^^^^^^^^^^^Full error text:
panic: interface conversion: ast.Expr is *ast.CompositeLit, not *ast.Ident
goroutine 1724 [running]:
sigs.k8s.io/controller-tools/pkg/loader.(*referenceCollector).Visit(0xc00afd77d0, {0xce75d0, 0xc009ce8348})
/home/joe/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:136 +0xff
go/ast.Walk({0xcdc280, 0xc00afd77d0}, {0xce75d0, 0xc009ce8348})
/usr/lib/go/src/go/ast/walk.go:50 +0x5f
go/ast.walkExprList({0xcdc280, 0xc00afd77d0}, {0xc006bbd610, 0x1, 0xc009f64080})
/usr/lib/go/src/go/ast/walk.go:24 +0x87
go/ast.Walk({0xcdc280, 0xc00afd77d0}, {0xce7058, 0xc009c74840})
/usr/lib/go/src/go/ast/walk.go:137 +0x92b
go/ast.Walk({0xcdc280, 0xc00afd77d0}, {0xce6fe0, 0xc00a15ea20})
/usr/lib/go/src/go/ast/walk.go:146 +0xdca
go/ast.Walk({0xcdc280, 0xc00afd77d0}, {0xce6ef0, 0xc00a15ea50})
/usr/lib/go/src/go/ast/walk.go:156 +0x1ad3
go/ast.Walk({0xcdc280, 0xc00afd77d0}, {0xce7238, 0xc009c74880})
/usr/lib/go/src/go/ast/walk.go:73 +0x6ba
go/ast.Walk({0xcdc280, 0xc00afd77d0}, {0xce7260, 0xc00a15ea80})
/usr/lib/go/src/go/ast/walk.go:84 +0x1f1a
go/ast.Walk({0xcdc280, 0xc00afd77d0}, {0xce7670, 0xc009ce8360})
/usr/lib/go/src/go/ast/walk.go:161 +0x16d2
sigs.k8s.io/controller-tools/pkg/loader.(*referenceSet).collectReferences(0xc00af88e80, {0xcea3e0, 0xc009ce8360}, 0xc0051d4b90)
/home/joe/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:107 +0xd3
sigs.k8s.io/controller-tools/pkg/loader.allReferencedPackages.func1(0x0, 0x8, 0xc00a15e9c0)
/home/joe/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:164 +0x52
sigs.k8s.io/controller-tools/pkg/loader.(*typeVisitor).Visit(0x415906, {0xce76e8, 0xc00a15e9c0})
/home/joe/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/visit.go:64 +0xe9
go/ast.Walk({0xcdc2a0, 0xc00af29ec0}, {0xce76e8, 0xc00a15e9c0})
/usr/lib/go/src/go/ast/walk.go:50 +0x5f
go/ast.Walk({0xcdc2a0, 0xc00af29ec0}, {0xce7350, 0xc009c748c0})
/usr/lib/go/src/go/ast/walk.go:333 +0x1e49
go/ast.walkDeclList({0xcdc2a0, 0xc00af29ec0}, {0xc005915f00, 0xb, 0x7f49e0487da8})
/usr/lib/go/src/go/ast/walk.go:36 +0x87
go/ast.Walk({0xcdc2a0, 0xc00af29ec0}, {0xce7288, 0xc007dc1200})
/usr/lib/go/src/go/ast/walk.go:355 +0x15c5
sigs.k8s.io/controller-tools/pkg/loader.EachType(0xc009935160, 0xc00af29ea8)
/home/joe/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/visit.go:38 +0x96
sigs.k8s.io/controller-tools/pkg/loader.allReferencedPackages(0xc009935160, 0xc0051d4b90)
/home/joe/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:162 +0x266
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0xc009eea780, 0xc009935160)
/home/joe/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:249 +0x187
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x34)
/home/joe/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:257 +0x65
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check
/home/joe/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:255 +0x1d2
Error: running "controller-gen object:headerFile="hack/boilerplate.go.txt" crd:trivialVersions=true,preserveUnknownFields=false rbac:roleName=manager-role paths="./..." output:crd:artifacts:config=config/crd/bases" failed with exit code 2
Here's the delve output of the value of node in pkg/loader/refs.go:136 at the time of the panic:
node: go/ast.Node(*go/ast.SelectorExpr) *{
X: go/ast.Expr(*go/ast.CompositeLit) *{
Type: go/ast.Expr(*go/ast.Ident) *{
NamePos: 10992551,
Name: "ifreq",
Obj: *go/ast.Object nil
},
Lbrace: 10992556,
Elts: []go/ast.Expr len: 0, cap: 0, nil,
Rbrace: 10992557,
Incomplete: false
},
Sel: *go/ast.Ident {
NamePos: 10992559,
Name: "Ifru",
Obj: *go/ast.Object nil
}
}armsnyder
Metadata
Metadata
Assignees
Labels
No labels