The Kubernetes Declarative Validation feature uses several custom string formats for validation in native types. This issue tracks making these formats available for CustomResourceDefinitions (CRDs).
Currently, kube-openapi supports k8s-short-name and k8s-long-name in kubernetes-extensions.go.
We want to also add support for the following additional formats defined in k/k format.go:
k8s-extended-resource-name
k8s-label-key
k8s-label-value
k8s-long-name-caseless
k8s-path-segment-name
k8s-resource-fully-qualified-name
k8s-resource-pool-name
k8s-uuid
Likely Implementation Steps (based on existing formats):
- In kubernetes-extensions.go, follow the pattern used for
ShortName and LongName.
- Define a new type for each format, e.g.:
// swagger:strfmt k8s-label-key
type LabelKey string
- Implement required methods for the type (
MarshalText, UnmarshalText, MarshalJSON, UnmarshalJSON, DeepCopyInto, DeepCopy, String).
- Define a regular expression and max length for validation.
- Register the format in the
init() function:
func init() {
// ...
labelKey := LabelKey("")
Default.Add(k8sPrefix+"label-key", &labelKey, IsLabelKey)
}
The Kubernetes Declarative Validation feature uses several custom string formats for validation in native types. This issue tracks making these formats available for CustomResourceDefinitions (CRDs).
Currently,
kube-openapisupportsk8s-short-nameandk8s-long-namein kubernetes-extensions.go.We want to also add support for the following additional formats defined in k/k format.go:
k8s-extended-resource-namek8s-label-keyk8s-label-valuek8s-long-name-caselessk8s-path-segment-namek8s-resource-fully-qualified-namek8s-resource-pool-namek8s-uuidLikely Implementation Steps (based on existing formats):
ShortNameandLongName.MarshalText,UnmarshalText,MarshalJSON,UnmarshalJSON,DeepCopyInto,DeepCopy,String).init()function: