Skip to content

Commit 911f008

Browse files
author
Alan Christie
committed
Support for constants
1 parent e8b7b08 commit 911f008

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

decoder/schema.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ definitions:
154154
value-from:
155155
oneOf:
156156
- $ref: '#/definitions/environment-value-from-api-token'
157+
- $ref: '#/definitions/environment-value-from-constant'
157158
- $ref: '#/definitions/environment-value-from-secret'
158159
required:
159160
- name
@@ -182,6 +183,22 @@ definitions:
182183
required:
183184
- api-token
184185

186+
# An Image environment from a constant.
187+
environment-value-from-constant:
188+
type: object
189+
additionalProperties: false
190+
properties:
191+
constant:
192+
type: object
193+
properties:
194+
# The hard-coded value (constant)
195+
value:
196+
type: string
197+
required:
198+
- value
199+
required:
200+
- constant
201+
185202
# An Image environment from a Kubernetes 'secret'.
186203
# At the moment we expect the secret to be unencrypted,
187204
# just 'opaque', so it can be read by the DM without special actions.

tests/test_validate_job_schema.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ def test_validate_image_env_from_api_token():
5050
assert error is None
5151

5252

53+
def test_validate_image_env_from_constant():
54+
# Arrange
55+
text: Dict[str, Any] = deepcopy(_MINIMAL)
56+
demo_job: Dict[str, Any] = text['jobs']['demo']
57+
demo_job['image']['environment'] = \
58+
[{'name': 'ENV_VAR',
59+
'value-from': {
60+
'constant': {
61+
'value': '123'}}}]
62+
63+
# Act
64+
error = decoder.validate_job_schema(text)
65+
66+
# Assert
67+
assert error is None
68+
69+
5370
def test_validate_image_env_from_secret():
5471
# Arrange
5572
text: Dict[str, Any] = deepcopy(_MINIMAL)

0 commit comments

Comments
 (0)