Skip to content

Commit 8c1fd63

Browse files
author
Alan Christie
committed
Now supports image memory and cores
1 parent 911f008 commit 8c1fd63

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

decoder/schema.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,32 @@ definitions:
130130
default: simple
131131
pull-secret:
132132
$ref: '#/definitions/rfc-1035-name'
133+
memory:
134+
$ref: '#/definitions/memory'
135+
cores:
136+
$ref: '#/definitions/cores'
133137
environment:
134138
$ref: '#/definitions/environment'
135139
required:
136140
- name
137141
- tag
138142
- project-directory
139143

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+
140159
# Image environment definitions.
141160
environment:
142161
type: array

tests/test_validate_job_schema.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,55 @@ def test_validate_image_env_from_secret():
8383

8484
# Assert
8585
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

0 commit comments

Comments
 (0)