Open
Description
What happened?
resource.Quantity
is converted to int-or-string
in CRD and cannot limit the maxLength of int-or-string
. The cost of quantity(self)
is too high and I cannot put it in a small array(maxItems=64)
I add maxLength
but not worked.
storage:
anyOf:
- type: integer
- type: string
description: Storage defines the request size
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
maxLength: 100
x-kubernetes-validations:
- rule: "quantity(self).isGreaterThan(quantity('0'))"
message: "test"
What did you expect to happen?
Decrease the cost of quantity()
or provide a way to limit the maxLength of resource.Quantity
How can we reproduce it (as minimally and precisely as possible)?
type Spec struct {
// maxItems=64
Array []Item
}
type Item struct {
// rule="quantity(self).isGreaterThan(quantity('0'))"
Size resource.Quantity
}
Anything else we need to know?
No response
Kubernetes version
$ kubectl version
1.30
Cloud provider
kind
OS version
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here
# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here