kubebuilder
kubebuilder copied to clipboard
versionPattern should be more flexible to allow internal versions
What broke? What's expected?
The versionPattern enforced by kubebuilder requires all CRD versions to start with a v, however this makes usage of an internal version confusing (e.g. creating a v0) where an internal or __internal version would communicate intent more clearly; __internal is even used within the core Kubernetes codebase.
What I'd like to see is the versionPattern relaxed to make an allowance for internal versions, something like so:
Before:
const (
versionPattern = "^v\\d+(?:alpha\\d+|beta\\d+)?$"
)
After:
const (
versionPattern = "^(?:__internal|v\\d+(?:alpha\\d+|beta\\d+)?)$"
)
Doing so would be additive and not break any of the existing uses.
Reproducing this issue
No response
KubeBuilder (CLI) Version
v3.12.0
PROJECT version
No response
Plugin versions
No response
Other versions
No response
Extra Labels
No response
Hi @robzienert
Thank you for raising this one. We should do the same k8s validation.
In this case, it might to be (Required to check): func IsDNS1035Label(value string) []string {
However, we need to TBD the right k8s validation and use the same. Feel free to check it out and open a PR with the proposed solution.
Your help is very welcome.
Hi @robzienert
My sincere apologies, I oversight this one. The PR https://github.com/kubernetes-sigs/kubebuilder/pull/3742 introduced an regression.
In Kubernetes Custom Resource Definitions (CRDs), Kind names must not include spaces, special characters (e.g., @, #, $, %, &, *), or punctuation marks. They should strictly adhere to CamelCase format, starting with an uppercase letter and not violating the general programming identifier rules (e.g., no starting with numbers, no reserved words). This ensures compatibility with Kubernetes API and client code generation tools.
The func IsDNS1035Label(value string) []string { is NOT accurated for this case.
The correct one seems to be (from the same file):
// IsDNS1123Subdomain tests for a string that conforms to the definition of a
// subdomain in DNS (RFC 1123).
func IsDNS1123Subdomain(value string) []string {
return dns1123SubdomainConfig.check(value)
}
Therefore, to close this one we need change the validation like was done in the PR https://github.com/kubernetes-sigs/kubebuilder/pull/3742
However, to avoid we introduce and issue we should add more tests in the project to ensure that names like DNS will be allowed to be used.
@camilamacedo86 is this really a good first issue? I dont see the clear cut implementation to close this issue.