-
Notifications
You must be signed in to change notification settings - Fork 429
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
Comments
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) |
It looks like |
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? |
Also hitting this with 0.17.1
|
^^ |
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
|
Interesting that our tests didn't catch this (cc @cbandy fyi) |
Can you please provide some code that reproduces the issue? |
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:
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
|
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
you'll get:
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 { |
That error comes from here: controller-tools/pkg/deepcopy/traverse.go Line 200 in d1f73b5
I'll try writing a test tonight. |
Fixes: kubernetes-sigs#1136 Signed-off-by: Chris Bandy <bandy.chris@gmail.com>
/reopen |
@sbueringer: Reopened this issue. In response to this:
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. |
@sbueringer yup this works 🎉
|
Similar to #1053 and #1076.
I am running into this error in CI (Go version 1.23) with the following stack trace:
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.
The text was updated successfully, but these errors were encountered: