-
Notifications
You must be signed in to change notification settings - Fork 431
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
Pathological CRD generation when struct names clash #1137
Comments
Not that I'm aware of. Sounds like a bug |
The following reproduces the issue. There should be no diff --git a/pkg/crd/testdata/multiple_versions/testdata.kubebuilder.io_bars.yaml b/pkg/crd/testdata/multiple_versions/testdata.kubebuilder.io_bars.yaml
index 5c5861e5..e3fd8ec0 100644
--- a/pkg/crd/testdata/multiple_versions/testdata.kubebuilder.io_bars.yaml
+++ b/pkg/crd/testdata/multiple_versions/testdata.kubebuilder.io_bars.yaml
@@ -14,6 +14,12 @@ spec:
singular: bar
scope: Namespaced
versions:
+ - name: v1beta1
+ schema:
+ openAPIV3Schema:
+ type: object
+ served: true
+ storage: false
- name: v1beta2
schema:
openAPIV3Schema:
diff --git a/pkg/crd/testdata/multiple_versions/v1beta1/types.go b/pkg/crd/testdata/multiple_versions/v1beta1/types.go
index 207ef5c7..02389b4b 100644
--- a/pkg/crd/testdata/multiple_versions/v1beta1/types.go
+++ b/pkg/crd/testdata/multiple_versions/v1beta1/types.go
@@ -43,3 +43,5 @@ type VersionedResourceList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []VersionedResource `json:"items"`
}
+
+type Bar struct{}
diff --git a/pkg/crd/testdata/multiple_versions/v1beta2/types.go b/pkg/crd/testdata/multiple_versions/v1beta2/types.go
index 8d98b876..22e20d0a 100644
--- a/pkg/crd/testdata/multiple_versions/v1beta2/types.go
+++ b/pkg/crd/testdata/multiple_versions/v1beta2/types.go
@@ -44,3 +44,11 @@ type VersionedResourceList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []VersionedResource `json:"items"`
}
+
+// +kubebuilder:object:root=true
+// +kubebuilder:storageversion
+
+type Bar struct {
+ metav1.TypeMeta `json:",inline"`
+ metav1.ObjectMeta `json:"metadata,omitempty"`
+} |
Definitely makes sense |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We have two packages/groups defined in our APIs directory. There is a struct with the same name in each; one of which is intended to generate a CRD, and one of which is just a field within another CRD.
Example:
When the CRDs get generated, we're seeing both a
v1alpha1
andv1beta2
resource version being created within the CRD.This is incorrect and results in the spec of the
Foo
being deleted due to some sort of conversion webhook mechanics.Is there a documented constraint that a struct with the same name as a kubebuilder object root cannot exist in another API version/package?
The text was updated successfully, but these errors were encountered: