File tree Expand file tree Collapse file tree 2 files changed +71
-0
lines changed Expand file tree Collapse file tree 2 files changed +71
-0
lines changed Original file line number Diff line number Diff line change @@ -130,13 +130,32 @@ definitions:
130
130
default : simple
131
131
pull-secret :
132
132
$ref : ' #/definitions/rfc-1035-name'
133
+ memory :
134
+ $ref : ' #/definitions/memory'
135
+ cores :
136
+ $ref : ' #/definitions/cores'
133
137
environment :
134
138
$ref : ' #/definitions/environment'
135
139
required :
136
140
- name
137
141
- tag
138
142
- project-directory
139
143
144
+ # A kubernetes CPU (cores) declaration.
145
+ # Here we only accept numbers in the range 1 to 32.
146
+ cores :
147
+ type : integer
148
+ minimum : 1
149
+ maximum : 32
150
+
151
+ # A kubernetes memory declaration.
152
+ # Here we only accept between 1 and 4 numbers
153
+ # and force a restricted suffix (Mi or Gi)
154
+ memory :
155
+ type : string
156
+ minLength : 1
157
+ pattern : ' ^[1-9][0-9]{0,3}(Gi|Mi)$'
158
+
140
159
# Image environment definitions.
141
160
environment :
142
161
type : array
Original file line number Diff line number Diff line change @@ -83,3 +83,55 @@ def test_validate_image_env_from_secret():
83
83
84
84
# Assert
85
85
assert error is None
86
+
87
+
88
+ def test_validate_image_memory_32gi ():
89
+ # Arrange
90
+ text : Dict [str , Any ] = deepcopy (_MINIMAL )
91
+ demo_job : Dict [str , Any ] = text ['jobs' ]['demo' ]
92
+ demo_job ['image' ]['memory' ] = '32Gi'
93
+
94
+ # Act
95
+ error = decoder .validate_job_schema (text )
96
+
97
+ # Assert
98
+ assert error is None
99
+
100
+
101
+ def test_validate_image_memory_500Mi ():
102
+ # Arrange
103
+ text : Dict [str , Any ] = deepcopy (_MINIMAL )
104
+ demo_job : Dict [str , Any ] = text ['jobs' ]['demo' ]
105
+ demo_job ['image' ]['memory' ] = '500Mi'
106
+
107
+ # Act
108
+ error = decoder .validate_job_schema (text )
109
+
110
+ # Assert
111
+ assert error is None
112
+
113
+
114
+ def test_validate_image_cores_1 ():
115
+ # Arrange
116
+ text : Dict [str , Any ] = deepcopy (_MINIMAL )
117
+ demo_job : Dict [str , Any ] = text ['jobs' ]['demo' ]
118
+ demo_job ['image' ]['cores' ] = 1
119
+
120
+ # Act
121
+ error = decoder .validate_job_schema (text )
122
+
123
+ # Assert
124
+ assert error is None
125
+
126
+
127
+ def test_validate_image_cores_32 ():
128
+ # Arrange
129
+ text : Dict [str , Any ] = deepcopy (_MINIMAL )
130
+ demo_job : Dict [str , Any ] = text ['jobs' ]['demo' ]
131
+ demo_job ['image' ]['cores' ] = 32
132
+
133
+ # Act
134
+ error = decoder .validate_job_schema (text )
135
+
136
+ # Assert
137
+ assert error is None
You can’t perform that action at this time.
0 commit comments