Skip to content

Commit 5e37914

Browse files
committed
Change Quantity types to int-or-string
Signed-off-by: Arjun Naik <[email protected]>
1 parent a5fa7b9 commit 5e37914

File tree

2 files changed

+47
-15
lines changed

2 files changed

+47
-15
lines changed

pkg/crd/known_types.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ var KnownPackages = map[string]PackageOverride{
5555
"k8s.io/apimachinery/pkg/api/resource": func(p *Parser, pkg *loader.Package) {
5656
p.Schemata[TypeIdent{Name: "Quantity", Package: pkg}] = apiext.JSONSchemaProps{
5757
// TODO(directxman12): regexp validation for this (or get kube to support it as a format value)
58-
Type: "string",
58+
XIntOrString: true,
59+
AnyOf: []apiext.JSONSchemaProps{
60+
{Type: "integer"},
61+
{Type: "string"},
62+
},
5963
}
6064
// No point in calling AddPackage, this is the sole inhabitant
6165
},

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

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,10 +1103,13 @@ spec:
11031103
for env vars'
11041104
type: string
11051105
divisor:
1106+
anyOf:
1107+
- type: integer
1108+
- type: string
11061109
description: Specifies the output
11071110
format of the exposed resources,
11081111
defaults to "1"
1109-
type: string
1112+
x-kubernetes-int-or-string: true
11101113
resource:
11111114
description: 'Required: resource
11121115
to select'
@@ -1767,14 +1770,20 @@ spec:
17671770
properties:
17681771
limits:
17691772
additionalProperties:
1770-
type: string
1773+
anyOf:
1774+
- type: integer
1775+
- type: string
1776+
x-kubernetes-int-or-string: true
17711777
description: 'Limits describes the maximum
17721778
amount of compute resources allowed. More
17731779
info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
17741780
type: object
17751781
requests:
17761782
additionalProperties:
1777-
type: string
1783+
anyOf:
1784+
- type: integer
1785+
- type: string
1786+
x-kubernetes-int-or-string: true
17781787
description: 'Requests describes the minimum
17791788
amount of compute resources required.
17801789
If Requests is omitted for a container,
@@ -2300,10 +2309,13 @@ spec:
23002309
for env vars'
23012310
type: string
23022311
divisor:
2312+
anyOf:
2313+
- type: integer
2314+
- type: string
23032315
description: Specifies the output
23042316
format of the exposed resources,
23052317
defaults to "1"
2306-
type: string
2318+
x-kubernetes-int-or-string: true
23072319
resource:
23082320
description: 'Required: resource
23092321
to select'
@@ -2964,14 +2976,20 @@ spec:
29642976
properties:
29652977
limits:
29662978
additionalProperties:
2967-
type: string
2979+
anyOf:
2980+
- type: integer
2981+
- type: string
2982+
x-kubernetes-int-or-string: true
29682983
description: 'Limits describes the maximum
29692984
amount of compute resources allowed. More
29702985
info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
29712986
type: object
29722987
requests:
29732988
additionalProperties:
2974-
type: string
2989+
anyOf:
2990+
- type: integer
2991+
- type: string
2992+
x-kubernetes-int-or-string: true
29752993
description: 'Requests describes the minimum
29762994
amount of compute resources required.
29772995
If Requests is omitted for a container,
@@ -3929,10 +3947,13 @@ spec:
39293947
for env vars'
39303948
type: string
39313949
divisor:
3950+
anyOf:
3951+
- type: integer
3952+
- type: string
39323953
description: Specifies the output
39333954
format of the exposed resources,
39343955
defaults to "1"
3935-
type: string
3956+
x-kubernetes-int-or-string: true
39363957
resource:
39373958
description: 'Required: resource
39383959
to select'
@@ -3958,6 +3979,9 @@ spec:
39583979
or Memory. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir'
39593980
type: string
39603981
sizeLimit:
3982+
anyOf:
3983+
- type: integer
3984+
- type: string
39613985
description: 'Total amount of local storage
39623986
required for this EmptyDir volume. The
39633987
size limit is also applicable for memory
@@ -3968,7 +3992,7 @@ spec:
39683992
a pod. The default is nil which means
39693993
that the limit is undefined. More info:
39703994
http://kubernetes.io/docs/user-guide/volumes#emptydir'
3971-
type: string
3995+
x-kubernetes-int-or-string: true
39723996
type: object
39733997
fc:
39743998
description: FC represents a Fibre Channel resource
@@ -4524,11 +4548,14 @@ spec:
45244548
for env vars'
45254549
type: string
45264550
divisor:
4551+
anyOf:
4552+
- type: integer
4553+
- type: string
45274554
description: Specifies
45284555
the output format
45294556
of the exposed resources,
45304557
defaults to "1"
4531-
type: string
4558+
x-kubernetes-int-or-string: true
45324559
resource:
45334560
description: 'Required:
45344561
resource to select'
@@ -4987,12 +5014,13 @@ spec:
49875014
type: object
49885015
type: object
49895016
mapOfInfo:
4990-
description: A map that allows different actors to manage different fields
4991-
type: object
4992-
x-kubernetes-map-type: granular
49935017
additionalProperties:
49945018
format: byte
49955019
type: string
5020+
description: A map that allows different actors to manage different
5021+
fields
5022+
type: object
5023+
x-kubernetes-map-type: granular
49965024
noReallySuspend:
49975025
description: This flag is like suspend, but for when you really mean
49985026
it. It helps test the +kubebuilder:validation:Type marker.
@@ -5019,8 +5047,6 @@ spec:
50195047
type: object
50205048
structWithSeveralFields:
50215049
description: A struct that can only be entirely replaced
5022-
type: object
5023-
x-kubernetes-map-type: atomic
50245050
properties:
50255051
bar:
50265052
type: boolean
@@ -5029,6 +5055,8 @@ spec:
50295055
required:
50305056
- bar
50315057
- foo
5058+
type: object
5059+
x-kubernetes-map-type: atomic
50325060
successfulJobsHistoryLimit:
50335061
description: The number of successful finished jobs to retain. This
50345062
is a pointer to distinguish between explicit zero and not specified.

0 commit comments

Comments
 (0)