Open scottd018 opened 2 years ago
This does work for multiple versions. Here is the snippet that works:
// +kubebuilder:storageversion
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// TanzuNamespace is the Schema for the tanzunamespaces API.
type TanzuNamespace struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec TanzuNamespaceSpec `json:"spec,omitempty"`
Status TanzuNamespaceStatus `json:"status,omitempty"`
}
Given that only one version can implement this functionality, we need to discuss how to handle this in our project.
The challenge here is that:
1) We can't implement this statically on all generated API versions, because only one version can have this feature. 2) It will be incredibly difficult, considering that controller-gen does the manifest generation for us, to ignore and/or remove the storage-version from an older API version.
Running
make manifests
results in the following:It appears adding
+kubebuilder:storageversion
will fix the issue (see https://github.com/kubernetes-sigs/controller-tools/issues/390). Anything else (e.g. I support v1beta2 but i submit a v1beta1 resources) will result in a conversion webhook doing the conversion.This doesn't appear to work when I try it, however I'm still playing around with this.