Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: interface conversion: types.Type is *types.Alias, not *types.Named (again) #1136

Open
jcardali opened this issue Jan 28, 2025 · 17 comments · Fixed by #1145
Open

panic: interface conversion: types.Type is *types.Alias, not *types.Named (again) #1136

jcardali opened this issue Jan 28, 2025 · 17 comments · Fixed by #1145

Comments

@jcardali
Copy link

jcardali commented Jan 28, 2025

Similar to #1053 and #1076.

I am running into this error in CI (Go version 1.23) with the following stack trace:

/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
panic: interface conversion: types.Type is *types.Alias, not *types.Named
goroutine 1 [running]:
sigs.k8s.io/controller-tools/pkg/deepcopy.shouldBeCopied(0xc000ec17e0, 0xc0508ef860)
	/pkg/mod/sigs.k8s.io/controller-tools@v0.17.0/pkg/deepcopy/traverse.go:623 +0x269
sigs.k8s.io/controller-tools/pkg/deepcopy.(*ObjectGenCtx).generateForPackage.func1(0xc0508ef860)
	/pkg/mod/sigs.k8s.io/controller-tools@v0.17.0/pkg/deepcopy/gen.go:229 +0x85
sigs.k8s.io/controller-tools/pkg/markers.EachType.func1(0xc0081390e0, 0xc009d45bc0, 0xc009d45b80)
	/pkg/mod/sigs.k8s.io/controller-tools@v0.17.0/pkg/markers/zip.go:222 +0x250
sigs.k8s.io/controller-tools/pkg/loader.(*typeVisitor).Visit(0x2c?, {0xec36a0?, 0xc009d45b80?})
	/pkg/mod/sigs.k8s.io/controller-tools@v0.17.0/pkg/loader/visit.go:64 +0xa7
go/ast.Walk({0xec0b00?, 0xc050964b40?}, {0xec36a0, 0xc009d45b80})
	/usr/local/go/src/go/ast/walk.go:34 +0x4c
go/ast.walkList[...](...)
	/usr/local/go/src/go/ast/walk.go:21
go/ast.Walk({0xec0b00?, 0xc050964b40?}, {0xec36f0, 0xc009d45bc0})
	/usr/local/go/src/go/ast/walk.go:320 +0x262d
go/ast.walkList[...](...)
	/usr/local/go/src/go/ast/walk.go:21
go/ast.Walk({0xec0b00?, 0xc050964b40?}, {0xec36c8, 0xc0081390e0})
	/usr/local/go/src/go/ast/walk.go:341 +0x3585
sigs.k8s.io/controller-tools/pkg/loader.EachType(0xc000ec17e0, 0xc050964b28)
	/pkg/mod/sigs.k8s.io/controller-tools@v0.17.0/pkg/loader/visit.go:38 +0x92
sigs.k8s.io/controller-tools/pkg/markers.EachType(0xc8e660?, 0xc000ec17e0, 0xc050bc6cc0)
	/pkg/mod/sigs.k8s.io/controller-tools@v0.17.0/pkg/markers/zip.go:198 +0x85
sigs.k8s.io/controller-tools/pkg/deepcopy.(*ObjectGenCtx).generateForPackage(0xc0565cfa70, 0xc000ec17e0)
	/pkg/mod/sigs.k8s.io/controller-tools@v0.17.0/pkg/deepcopy/gen.go:219 +0x247
sigs.k8s.io/controller-tools/pkg/deepcopy.Generator.Generate({{0xc00003da4b?, 0x411f01?}, {0x0?, 0xd26de0?}}, 0xc00021c280)
	/pkg/mod/sigs.k8s.io/controller-tools@v0.17.0/pkg/deepcopy/gen.go:155 +0x213
sigs.k8s.io/controller-tools/pkg/genall.(*Runtime).Run(0xc002503830)
	/pkg/mod/sigs.k8s.io/controller-tools@v0.17.0/pkg/genall/genall.go:272 +0x234
main.main.func1(0xc0001f2200?, {0xc00009d960?, 0x4?, 0xd7195b?})
	/pkg/mod/sigs.k8s.io/controller-tools@v0.17.0/cmd/controller-gen/main.go:176 +0x6a
github.com/spf13/cobra.(*Command).execute(0xc000202c08, {0xc000036130, 0x2, 0x2})
	/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0xaaa
github.com/spf13/cobra.(*Command).ExecuteC(0xc000202c08)
	/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041
main.main()
	/pkg/mod/sigs.k8s.io/controller-tools@v0.17.0/cmd/controller-gen/main.go:200 +0x2f6
make: *** [Makefile:68: generate] Error 2

Running controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..." on my local machine yields no errors.

Please let me know if there is any information I've omitted that might be helpful.

@sbueringer
Copy link
Member

Can you please check if this also happens with controller-gen compiled from the main branch?

I think this PR might have fixed it: #1119 (it's not released yet)

@jcardali
Copy link
Author

It looks like controller-tools@main does get past this issue, I'm now seeing the same invalid type: interface{} as I was on v16

@sbueringer
Copy link
Member

sbueringer commented Feb 3, 2025

I'm now seeing the same invalid type: interface{} as I was on v16

Not sure if this means we still have another issue in controller-gen. If yes, can you provide more details?

I assume v16 is v0.16?

@pmalek
Copy link
Contributor

pmalek commented Feb 4, 2025

Also hitting this with 0.17.1

/Users/USER/code_/kubernetes-configuration/bin/installs/kube-controller-tools/0.17.1/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./api/configuration/...;./api/konnect/..."
panic: interface conversion: types.Type is *types.Alias, not *types.Named

goroutine 1 [running]:
sigs.k8s.io/controller-tools/pkg/deepcopy.shouldBeCopied(0x14000452fc0, 0x140082bc420)
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/sigs.k8s.io/controller-tools@v0.17.1/pkg/deepcopy/traverse.go:623 +0x27c
sigs.k8s.io/controller-tools/pkg/deepcopy.(*ObjectGenCtx).generateForPackage.func1(0x140082bc420)
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/sigs.k8s.io/controller-tools@v0.17.1/pkg/deepcopy/gen.go:229 +0x6c
sigs.k8s.io/controller-tools/pkg/markers.EachType.func1(0x1400090a000, 0x14000906080, 0x14000906040)
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/sigs.k8s.io/controller-tools@v0.17.1/pkg/markers/zip.go:222 +0x1f0
sigs.k8s.io/controller-tools/pkg/loader.(*typeVisitor).Visit(0x14000baf700?, {0x103a26480?, 0x14000906040?})
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/sigs.k8s.io/controller-tools@v0.17.1/pkg/loader/visit.go:64 +0xc0
go/ast.Walk({0x103a23800?, 0x14007cfd008?}, {0x103a26480, 0x14000906040})
        /Users/USER/.gvm/gos/go1.23.4/src/go/ast/walk.go:34 +0x44
go/ast.walkList[...](...)
        /Users/USER/.gvm/gos/go1.23.4/src/go/ast/walk.go:21
go/ast.Walk({0x103a23800?, 0x14007cfd008?}, {0x103a264d0, 0x14000906080})
        /Users/USER/.gvm/gos/go1.23.4/src/go/ast/walk.go:320 +0x20f4
go/ast.walkList[...](...)
        /Users/USER/.gvm/gos/go1.23.4/src/go/ast/walk.go:21
go/ast.Walk({0x103a23800?, 0x14007cfd008?}, {0x103a264a8, 0x1400090a000})
        /Users/USER/.gvm/gos/go1.23.4/src/go/ast/walk.go:341 +0x2e24
sigs.k8s.io/controller-tools/pkg/loader.EachType(0x14000452fc0, 0x14007cfcff0)
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/sigs.k8s.io/controller-tools@v0.17.1/pkg/loader/visit.go:38 +0x98
sigs.k8s.io/controller-tools/pkg/markers.EachType(0x10393a720?, 0x14000452fc0, 0x140053f2660)
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/sigs.k8s.io/controller-tools@v0.17.1/pkg/markers/zip.go:198 +0x84
sigs.k8s.io/controller-tools/pkg/deepcopy.(*ObjectGenCtx).generateForPackage(0x14001107a38, 0x14000452fc0)
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/sigs.k8s.io/controller-tools@v0.17.1/pkg/deepcopy/gen.go:219 +0x204
sigs.k8s.io/controller-tools/pkg/deepcopy.Generator.Generate({{0x140001974ab?, 0x1039bc5a0?}, {0x0?, 0x10368fee0?}}, 0x14000064690)
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/sigs.k8s.io/controller-tools@v0.17.1/pkg/deepcopy/gen.go:155 +0x188
sigs.k8s.io/controller-tools/pkg/genall.(*Runtime).Run(0x140001ddb90)
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/sigs.k8s.io/controller-tools@v0.17.1/pkg/genall/genall.go:272 +0x21c
main.main.func1(0x1400030c200?, {0x140001bd960?, 0x4?, 0x10374fa54?})
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/sigs.k8s.io/controller-tools@v0.17.1/cmd/controller-gen/main.go:176 +0x64
github.com/spf13/cobra.(*Command).execute(0x1400031cc08, {0x1400018c0d0, 0x2, 0x2})
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0x834
github.com/spf13/cobra.(*Command).ExecuteC(0x1400031cc08)
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041
main.main()
        /Users/USER/.gvm/pkgsets/go1.23.4/global/pkg/mod/sigs.k8s.io/controller-tools@v0.17.1/cmd/controller-gen/main.go:200 +0x290

@sbueringer
Copy link
Member

Can you please check if this also happens with controller-gen compiled from the main branch?

^^

@pmalek
Copy link
Contributor

pmalek commented Feb 4, 2025

main (d1f73b5) doesn't seem to panic but it fails in other ways:

./controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./api/configuration/...;./api/konnect/..."

github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1beta1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
Error: not all generators ran successfully
run `controller-gen object:headerFile=hack/boilerplate.go.txt paths=./api/configuration/...;./api/konnect/... -w` to see all available markers, or `controller-gen object:headerFile=hack/boilerplate.go.txt paths=./api/configuration/...;./api/konnect/... -h` for usage

I can see the type name being expanded to full name including the package name:

index 22477b4..ba8de3c 100644
--- a/api/configuration/v1beta1/zz_generated.deepcopy.go
+++ b/api/configuration/v1beta1/zz_generated.deepcopy.go
@@ -22,8 +22,7 @@ package v1beta1

 import (
        "github.com/kong/kubernetes-configuration/api/configuration/common"
-       "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1"
-       konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1"
+       "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1"
        "k8s.io/apimachinery/pkg/apis/meta/v1"
        runtime "k8s.io/apimachinery/pkg/runtime"
 )
@@ -143,7 +142,7 @@ func (in *KongConsumerGroupSpec) DeepCopyInto(out *KongConsumerGroupSpec) {
        *out = *in
        if in.ControlPlaneRef != nil {
                in, out := &in.ControlPlaneRef, &out.ControlPlaneRef
-               *out = new(v1alpha1.ControlPlaneRef)
+               *out = new(github.com/kong/kubernetes - configuration/api/configuration/v1alpha1.ControlPlaneRef)
                (*in).DeepCopyInto(*out)
        }

running

go version -m ./controller-gen
./controller-gen: go1.23.4
        path    sigs.k8s.io/controller-tools/cmd/controller-gen
        mod     sigs.k8s.io/controller-tools    (devel)
...
        build   -buildmode=exe
        build   -compiler=gc
        build   CGO_ENABLED=1
        build   CGO_CFLAGS=
        build   CGO_CPPFLAGS=
        build   CGO_CXXFLAGS=
        build   CGO_LDFLAGS=
        build   GOARCH=arm64
        build   GOOS=darwin
        build   GOARM64=v8.0
        build   vcs=git
        build   vcs.revision=d1f73b5ea552bd1ca82ff2363dbd079f5c145df4
        build   vcs.time=2025-02-03T10:00:58Z
        build   vcs.modified=true

@sbueringer
Copy link
Member

Interesting that our tests didn't catch this

(cc @cbandy fyi)

@cbandy
Copy link
Contributor

cbandy commented Feb 4, 2025

Can you please provide some code that reproduces the issue?

@pmalek
Copy link
Contributor

pmalek commented Feb 4, 2025

@cbandy
Copy link
Contributor

cbandy commented Feb 4, 2025

Please check that you are running the main branch of controller-gen.

There is a mistake in the code you posted. The v1alpha package references the common package, but the latter is not considered by controller-gen:

$ go install sigs.k8s.io/controller-tools/cmd/controller-gen@main
…
$ go version -m $(command -v controller-gen)
/home/bandychris/go/bin/controller-gen: go1.23.2
        path    sigs.k8s.io/controller-tools/cmd/controller-gen
        mod     sigs.k8s.io/controller-tools    v0.17.2-0.20250203100058-d1f73b5ea552   h1:0A2ZeOcfGlEAKlvrlJMKesUvyKI3EodYTNiBscZiNVU=
…
$ git clone https://github.com/pmalek/crd-alias-fail.git
…
$ cd crd-alias-fail
$ git rev-parse HEAD
183efad9c6bfb1db45ad0331a9307afcd65b502b

$ controller-gen object paths="./api/configuration/...;./api/konnect/..."
# (success)

$ go test ./...
?       github.com/pmalek/crd-alias-fail/api/configuration/common       [no test files]
# github.com/pmalek/crd-alias-fail/api/konnect/v1alpha1
api/konnect/v1alpha1/zz_generated.deepcopy.go:10:7: cannot define new methods on non-local type ControlPlaneRef
api/konnect/v1alpha1/zz_generated.deepcopy.go:15:7: cannot define new methods on non-local type ControlPlaneRef
FAIL    github.com/pmalek/crd-alias-fail/api/konnect/v1alpha1 [build failed]
FAIL

The following change to your code seems to fix everything. Notice I had to delete the deepcopy file from the v1alpha1 package because there is no longer anything to generate there.

diff --git a/api/configuration/common/controlplaneref_types.go b/api/configuration/common/controlplaneref_types.go
index 9fddf83..4ecd2c0 100644
--- a/api/configuration/common/controlplaneref_types.go
+++ b/api/configuration/common/controlplaneref_types.go
@@ -1,3 +1,4 @@
+// +kubebuilder:object:generate=true
 package common
 
 type ControlPlaneRef struct {
diff --git a/api/konnect/v1alpha1/zz_generated.deepcopy.go b/api/konnect/v1alpha1/zz_generated.deepcopy.go
deleted file mode 100644
index a0d3e7f..0000000
--- a/api/konnect/v1alpha1/zz_generated.deepcopy.go
+++ /dev/null
$ controller-gen object paths="./api/configuration/...;./api/konnect/..."
# (success)

$ go test ./...
?       github.com/pmalek/crd-alias-fail/api/configuration/common       [no test files]
?       github.com/pmalek/crd-alias-fail/api/konnect/v1alpha1   [no test files]

@pmalek
Copy link
Contributor

pmalek commented Feb 4, 2025

That's true. I believe I missed something trying to provide minimal reproduction code.

When you check out https://github.com/pmalek/kubernetes-configuration/tree/controller-tools-1136 and run

controller-gen --version
Version: v0.17.2-0.20250203100058-d1f73b5ea552

controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./api/configuration/...;./api/konnect/..."

you'll get:


github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1alpha1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
github.com/kong/kubernetes-configuration/api/configuration/v1beta1:-: name requested for invalid type: github.com/kong/kubernetes-configuration/api/configuration/v1alpha1.ControlPlaneRef
Error: not all generators ran successfully
run `controller-gen object:headerFile=hack/boilerplate.go.txt paths=./api/configuration/...;./api/konnect/... -w` to see all available markers, or `controller-gen object:headerFile=hack/boilerplate.go.txt paths=./api/configuration/...;./api/konnect/... -h` for usage

and the following diff

diff --git a/api/configuration/v1/zz_generated.deepcopy.go b/api/configuration/v1/zz_generated.deepcopy.go
index a9672ba..5cfc7ca 100644
--- a/api/configuration/v1/zz_generated.deepcopy.go
+++ b/api/configuration/v1/zz_generated.deepcopy.go
@@ -23,8 +23,7 @@ package v1
 import (
 	"github.com/kong/go-kong/kong"
 	"github.com/kong/kubernetes-configuration/api/configuration/common"
-	"github.com/kong/kubernetes-configuration/api/configuration/v1alpha1"
-	konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1"
+	"github.com/kong/kubernetes-configuration/api/konnect/v1alpha1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	runtime "k8s.io/apimachinery/pkg/runtime"
 )
@@ -236,7 +235,7 @@ func (in *KongConsumerSpec) DeepCopyInto(out *KongConsumerSpec) {
 	*out = *in
 	if in.ControlPlaneRef != nil {
 		in, out := &in.ControlPlaneRef, &out.ControlPlaneRef
-		*out = new(v1alpha1.ControlPlaneRef)
+		*out = new(github.com/kong/kubernetes - configuration/api/configuration/v1alpha1.ControlPlaneRef)
 		(*in).DeepCopyInto(*out)
 	}
 	if in.Tags != nil {
@@ -261,7 +260,7 @@ func (in *KongConsumerStatus) DeepCopyInto(out *KongConsumerStatus) {
 	*out = *in
 	if in.Konnect != nil {
 		in, out := &in.Konnect, &out.Konnect
-		*out = new(konnectv1alpha1.KonnectEntityStatusWithControlPlaneRef)
+		*out = new(v1alpha1.KonnectEntityStatusWithControlPlaneRef)
 		**out = **in
 	}
 	if in.Conditions != nil {
diff --git a/api/configuration/v1alpha1/zz_generated.deepcopy.go b/api/configuration/v1alpha1/zz_generated.deepcopy.go
index 56873de..ec390dd 100644
--- a/api/configuration/v1alpha1/zz_generated.deepcopy.go
+++ b/api/configuration/v1alpha1/zz_generated.deepcopy.go
@@ -28,31 +28,6 @@ import (
 	runtime "k8s.io/apimachinery/pkg/runtime"
 )
 
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *ControlPlaneRef) DeepCopyInto(out *ControlPlaneRef) {
-	*out = *in
-	if in.KonnectID != nil {
-		in, out := &in.KonnectID, &out.KonnectID
-		*out = new(string)
-		**out = **in
-	}
-	if in.KonnectNamespacedRef != nil {
-		in, out := &in.KonnectNamespacedRef, &out.KonnectNamespacedRef
-		*out = new(common.KonnectNamespacedRef)
-		**out = **in
-	}
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControlPlaneRef.
-func (in *ControlPlaneRef) DeepCopy() *ControlPlaneRef {
-	if in == nil {
-		return nil
-	}
-	out := new(ControlPlaneRef)
-	in.DeepCopyInto(out)
-	return out
-}
-
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *ControllerReference) DeepCopyInto(out *ControllerReference) {
 	*out = *in
@@ -280,7 +255,7 @@ func (in *KongCACertificateSpec) DeepCopyInto(out *KongCACertificateSpec) {
 	*out = *in
 	if in.ControlPlaneRef != nil {
 		in, out := &in.ControlPlaneRef, &out.ControlPlaneRef
-		*out = new(ControlPlaneRef)
+		*out = new(github.com/kong/kubernetes - configuration/api/configuration/v1alpha1.ControlPlaneRef)
 		(*in).DeepCopyInto(*out)
 	}
 	in.KongCACertificateAPISpec.DeepCopyInto(&out.KongCACertificateAPISpec)
@@ -407,7 +382,7 @@ func (in *KongCertificateSpec) DeepCopyInto(out *KongCertificateSpec) {
 	*out = *in
 	if in.ControlPlaneRef != nil {
 		in, out := &in.ControlPlaneRef, &out.ControlPlaneRef
-		*out = new(ControlPlaneRef)
+		*out = new(github.com/kong/kubernetes - configuration/api/configuration/v1alpha1.ControlPlaneRef)
 		(*in).DeepCopyInto(*out)
 	}
 	in.KongCertificateAPISpec.DeepCopyInto(&out.KongCertificateAPISpec)
@@ -1281,7 +1256,7 @@ func (in *KongDataPlaneClientCertificateSpec) DeepCopyInto(out *KongDataPlaneCli
 	*out = *in
 	if in.ControlPlaneRef != nil {
 		in, out := &in.ControlPlaneRef, &out.ControlPlaneRef
-		*out = new(ControlPlaneRef)
+		*out = new(github.com/kong/kubernetes - configuration/api/configuration/v1alpha1.ControlPlaneRef)
 		(*in).DeepCopyInto(*out)
 	}
 	out.KongDataPlaneClientCertificateAPISpec = in.KongDataPlaneClientCertificateAPISpec
@@ -1502,7 +1477,7 @@ func (in *KongKeySetSpec) DeepCopyInto(out *KongKeySetSpec) {
 	*out = *in
 	if in.ControlPlaneRef != nil {
 		in, out := &in.ControlPlaneRef, &out.ControlPlaneRef
-		*out = new(ControlPlaneRef)
+		*out = new(github.com/kong/kubernetes - configuration/api/configuration/v1alpha1.ControlPlaneRef)
 		(*in).DeepCopyInto(*out)
 	}
 	in.KongKeySetAPISpec.DeepCopyInto(&out.KongKeySetAPISpec)
@@ -1550,7 +1525,7 @@ func (in *KongKeySpec) DeepCopyInto(out *KongKeySpec) {
 	*out = *in
 	if in.ControlPlaneRef != nil {
 		in, out := &in.ControlPlaneRef, &out.ControlPlaneRef
-		*out = new(ControlPlaneRef)
+		*out = new(github.com/kong/kubernetes - configuration/api/configuration/v1alpha1.ControlPlaneRef)
 		(*in).DeepCopyInto(*out)
 	}
 	if in.KeySetRef != nil {
@@ -2042,7 +2017,7 @@ func (in *KongRouteSpec) DeepCopyInto(out *KongRouteSpec) {
 	*out = *in
 	if in.ControlPlaneRef != nil {
 		in, out := &in.ControlPlaneRef, &out.ControlPlaneRef
-		*out = new(ControlPlaneRef)
+		*out = new(github.com/kong/kubernetes - configuration/api/configuration/v1alpha1.ControlPlaneRef)
 		(*in).DeepCopyInto(*out)
 	}
 	if in.ServiceRef != nil {
@@ -2347,7 +2322,7 @@ func (in *KongServiceSpec) DeepCopyInto(out *KongServiceSpec) {
 	*out = *in
 	if in.ControlPlaneRef != nil {
 		in, out := &in.ControlPlaneRef, &out.ControlPlaneRef
-		*out = new(ControlPlaneRef)
+		*out = new(github.com/kong/kubernetes - configuration/api/configuration/v1alpha1.ControlPlaneRef)
 		(*in).DeepCopyInto(*out)
 	}
 	in.KongServiceAPISpec.DeepCopyInto(&out.KongServiceAPISpec)
@@ -2677,7 +2652,7 @@ func (in *KongUpstreamSpec) DeepCopyInto(out *KongUpstreamSpec) {
 	*out = *in
 	if in.ControlPlaneRef != nil {
 		in, out := &in.ControlPlaneRef, &out.ControlPlaneRef
-		*out = new(ControlPlaneRef)
+		*out = new(github.com/kong/kubernetes - configuration/api/configuration/v1alpha1.ControlPlaneRef)
 		(*in).DeepCopyInto(*out)
 	}
 	in.KongUpstreamAPISpec.DeepCopyInto(&out.KongUpstreamAPISpec)
@@ -2790,7 +2765,7 @@ func (in *KongVaultSpec) DeepCopyInto(out *KongVaultSpec) {
 	}
 	if in.ControlPlaneRef != nil {
 		in, out := &in.ControlPlaneRef, &out.ControlPlaneRef
-		*out = new(ControlPlaneRef)
+		*out = new(github.com/kong/kubernetes - configuration/api/configuration/v1alpha1.ControlPlaneRef)
 		(*in).DeepCopyInto(*out)
 	}
 }
diff --git a/api/configuration/v1beta1/zz_generated.deepcopy.go b/api/configuration/v1beta1/zz_generated.deepcopy.go
index 22477b4..ba8de3c 100644
--- a/api/configuration/v1beta1/zz_generated.deepcopy.go
+++ b/api/configuration/v1beta1/zz_generated.deepcopy.go
@@ -22,8 +22,7 @@ package v1beta1
 
 import (
 	"github.com/kong/kubernetes-configuration/api/configuration/common"
-	"github.com/kong/kubernetes-configuration/api/configuration/v1alpha1"
-	konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1"
+	"github.com/kong/kubernetes-configuration/api/konnect/v1alpha1"
 	"k8s.io/apimachinery/pkg/apis/meta/v1"
 	runtime "k8s.io/apimachinery/pkg/runtime"
 )
@@ -143,7 +142,7 @@ func (in *KongConsumerGroupSpec) DeepCopyInto(out *KongConsumerGroupSpec) {
 	*out = *in
 	if in.ControlPlaneRef != nil {
 		in, out := &in.ControlPlaneRef, &out.ControlPlaneRef
-		*out = new(v1alpha1.ControlPlaneRef)
+		*out = new(github.com/kong/kubernetes - configuration/api/configuration/v1alpha1.ControlPlaneRef)
 		(*in).DeepCopyInto(*out)
 	}
 	if in.Tags != nil {
@@ -168,7 +167,7 @@ func (in *KongConsumerGroupStatus) DeepCopyInto(out *KongConsumerGroupStatus) {
 	*out = *in
 	if in.Konnect != nil {
 		in, out := &in.Konnect, &out.Konnect
-		*out = new(konnectv1alpha1.KonnectEntityStatusWithControlPlaneRef)
+		*out = new(v1alpha1.KonnectEntityStatusWithControlPlaneRef)
 		**out = **in
 	}
 	if in.Conditions != nil {

@cbandy
Copy link
Contributor

cbandy commented Feb 5, 2025

That error comes from here:

basePkg.AddError(fmt.Errorf("name requested for invalid type: %s", typeInfo))

I'll try writing a test tonight.

cbandy added a commit to cbandy/controller-tools that referenced this issue Feb 5, 2025
Fixes: kubernetes-sigs#1136
Signed-off-by: Chris Bandy <bandy.chris@gmail.com>
@cbandy
Copy link
Contributor

cbandy commented Feb 5, 2025

@pmalek thank you for your persistence! This should be resolved by #1145.

@sbueringer
Copy link
Member

@cbandy @pmalek Thx both of you for working on this!

@pmalek @jcardali Is the version on main now working for both of you? I would cut a new patch release once I got confirmation

@sbueringer
Copy link
Member

/reopen
(for confirmation)

@k8s-ci-robot k8s-ci-robot reopened this Feb 5, 2025
@k8s-ci-robot
Copy link
Contributor

@sbueringer: Reopened this issue.

In response to this:

/reopen
(for confirmation)

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@pmalek
Copy link
Contributor

pmalek commented Feb 5, 2025

@sbueringer yup this works 🎉

$ controller-gen --version

Version: v0.17.2-0.20250205103018-dac769d27bbe
$ controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./api/configuration/...;./api/konnect/..." 
$ echo $?
0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants