Skip to content

Commit 5c28250

Browse files
committed
Added pattern for quantity validation
Signed-off-by: Arjun Naik <[email protected]>
1 parent 5e37914 commit 5c28250

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/crd/known_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ var KnownPackages = map[string]PackageOverride{
6060
{Type: "integer"},
6161
{Type: "string"},
6262
},
63+
Pattern: "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTIE]i)|[mkMGTPE]|((\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$",
6364
}
6465
// No point in calling AddPackage, this is the sole inhabitant
6566
},

pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,7 @@ spec:
11091109
description: Specifies the output
11101110
format of the exposed resources,
11111111
defaults to "1"
1112+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTIE]i)|[mkMGTPE]|((\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
11121113
x-kubernetes-int-or-string: true
11131114
resource:
11141115
description: 'Required: resource
@@ -1773,6 +1774,7 @@ spec:
17731774
anyOf:
17741775
- type: integer
17751776
- type: string
1777+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTIE]i)|[mkMGTPE]|((\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
17761778
x-kubernetes-int-or-string: true
17771779
description: 'Limits describes the maximum
17781780
amount of compute resources allowed. More
@@ -1783,6 +1785,7 @@ spec:
17831785
anyOf:
17841786
- type: integer
17851787
- type: string
1788+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTIE]i)|[mkMGTPE]|((\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
17861789
x-kubernetes-int-or-string: true
17871790
description: 'Requests describes the minimum
17881791
amount of compute resources required.
@@ -2315,6 +2318,7 @@ spec:
23152318
description: Specifies the output
23162319
format of the exposed resources,
23172320
defaults to "1"
2321+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTIE]i)|[mkMGTPE]|((\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
23182322
x-kubernetes-int-or-string: true
23192323
resource:
23202324
description: 'Required: resource
@@ -2979,6 +2983,7 @@ spec:
29792983
anyOf:
29802984
- type: integer
29812985
- type: string
2986+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTIE]i)|[mkMGTPE]|((\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
29822987
x-kubernetes-int-or-string: true
29832988
description: 'Limits describes the maximum
29842989
amount of compute resources allowed. More
@@ -2989,6 +2994,7 @@ spec:
29892994
anyOf:
29902995
- type: integer
29912996
- type: string
2997+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTIE]i)|[mkMGTPE]|((\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
29922998
x-kubernetes-int-or-string: true
29932999
description: 'Requests describes the minimum
29943000
amount of compute resources required.
@@ -3953,6 +3959,7 @@ spec:
39533959
description: Specifies the output
39543960
format of the exposed resources,
39553961
defaults to "1"
3962+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTIE]i)|[mkMGTPE]|((\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
39563963
x-kubernetes-int-or-string: true
39573964
resource:
39583965
description: 'Required: resource
@@ -3992,6 +3999,7 @@ spec:
39923999
a pod. The default is nil which means
39934000
that the limit is undefined. More info:
39944001
http://kubernetes.io/docs/user-guide/volumes#emptydir'
4002+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTIE]i)|[mkMGTPE]|((\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
39954003
x-kubernetes-int-or-string: true
39964004
type: object
39974005
fc:
@@ -4555,6 +4563,7 @@ spec:
45554563
the output format
45564564
of the exposed resources,
45574565
defaults to "1"
4566+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTIE]i)|[mkMGTPE]|((\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
45584567
x-kubernetes-int-or-string: true
45594568
resource:
45604569
description: 'Required:

0 commit comments

Comments
 (0)