opentf-toolkit-nightly 0.56.0.dev985__py3-none-any.whl → 0.56.0.dev994__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opentf/commons/expressions.py +22 -4
- opentf/commons/schemas.py +1 -1
- opentf/schemas/opentestfactory.org/v1/Workflow.json +473 -0
- opentf/toolkit/__init__.py +44 -0
- opentf/toolkit/core.py +11 -0
- {opentf_toolkit_nightly-0.56.0.dev985.dist-info → opentf_toolkit_nightly-0.56.0.dev994.dist-info}/METADATA +1 -1
- {opentf_toolkit_nightly-0.56.0.dev985.dist-info → opentf_toolkit_nightly-0.56.0.dev994.dist-info}/RECORD +10 -9
- {opentf_toolkit_nightly-0.56.0.dev985.dist-info → opentf_toolkit_nightly-0.56.0.dev994.dist-info}/LICENSE +0 -0
- {opentf_toolkit_nightly-0.56.0.dev985.dist-info → opentf_toolkit_nightly-0.56.0.dev994.dist-info}/WHEEL +0 -0
- {opentf_toolkit_nightly-0.56.0.dev985.dist-info → opentf_toolkit_nightly-0.56.0.dev994.dist-info}/top_level.txt +0 -0
opentf/commons/expressions.py
CHANGED
|
@@ -76,6 +76,8 @@ DATETIME_FUNCTIONS = (
|
|
|
76
76
|
'second',
|
|
77
77
|
)
|
|
78
78
|
|
|
79
|
+
SPECIAL_FUNCTIONS = '__special functions__'
|
|
80
|
+
|
|
79
81
|
########################################################################
|
|
80
82
|
## Tokenizer
|
|
81
83
|
|
|
@@ -382,16 +384,29 @@ def evaluate_function_arity_2(name: str, arg1, arg2) -> bool:
|
|
|
382
384
|
|
|
383
385
|
|
|
384
386
|
def evaluate_status_function(name: str, contexts) -> bool:
|
|
385
|
-
"""Evaluate job status function.
|
|
387
|
+
"""Evaluate job status function.
|
|
388
|
+
|
|
389
|
+
Annotates the contexts[SPECIAL_FUNCTIONS] entry with a `__called__`
|
|
390
|
+
sub-entry if appropriate, so that caller can detect status function
|
|
391
|
+
usage.
|
|
392
|
+
"""
|
|
393
|
+
if name not in ('always', 'success', 'failure', 'cancelled'):
|
|
394
|
+
raise ValueError(f'Unknown function {name}()')
|
|
395
|
+
# a status function has been used
|
|
396
|
+
if SPECIAL_FUNCTIONS in contexts:
|
|
397
|
+
contexts[SPECIAL_FUNCTIONS]['__called__'] = True
|
|
386
398
|
if name == 'always':
|
|
387
399
|
return True
|
|
400
|
+
if external_functions := contexts.get(SPECIAL_FUNCTIONS):
|
|
401
|
+
if name in external_functions:
|
|
402
|
+
return external_functions[name]
|
|
403
|
+
raise ValueError(f'Unknown function {name}()')
|
|
388
404
|
if name == 'success':
|
|
389
405
|
return contexts['job']['status'] == 'success'
|
|
390
406
|
if name == 'failure':
|
|
391
407
|
return contexts['job']['status'] == 'failure'
|
|
392
408
|
if name == 'cancelled':
|
|
393
409
|
return contexts['job']['status'] == 'cancelled'
|
|
394
|
-
raise ValueError(f'Unknown function {name}()')
|
|
395
410
|
|
|
396
411
|
|
|
397
412
|
def _evaluate_identifier(
|
|
@@ -484,7 +499,7 @@ def _evaluate_expression(
|
|
|
484
499
|
infix = '==' | '!=' | '<=' | '<' | '>' | '>=' | '~='
|
|
485
500
|
expression = term ('&&' term | '||' term)*
|
|
486
501
|
term = factor (infix factor)?
|
|
487
|
-
factor = path | string | number | !factor | (expression)
|
|
502
|
+
factor = path | string | number | '!'factor | '('expression')'
|
|
488
503
|
|
|
489
504
|
# Required parameters
|
|
490
505
|
|
|
@@ -628,7 +643,7 @@ def evaluate_items(items: Dict[str, Any], contexts) -> Dict[str, Any]:
|
|
|
628
643
|
return result
|
|
629
644
|
|
|
630
645
|
|
|
631
|
-
def evaluate_bool(expr: str, contexts) -> bool:
|
|
646
|
+
def evaluate_bool(expr: str, contexts, special_functions=None) -> bool:
|
|
632
647
|
"""Evaluate expression in context.
|
|
633
648
|
|
|
634
649
|
`expr` may be surrounded by `${{` and `}}`.
|
|
@@ -643,6 +658,9 @@ def evaluate_bool(expr: str, contexts) -> bool:
|
|
|
643
658
|
A boolean.
|
|
644
659
|
"""
|
|
645
660
|
expr = _maybe_remove_expression_syntax(expr)
|
|
661
|
+
if special_functions:
|
|
662
|
+
contexts = contexts.copy()
|
|
663
|
+
contexts[SPECIAL_FUNCTIONS] = special_functions
|
|
646
664
|
if '${{' in expr:
|
|
647
665
|
return _to_number(evaluate_str(expr, contexts)) != 0
|
|
648
666
|
return _to_number(evaluate(expr, contexts)) != 0
|
opentf/commons/schemas.py
CHANGED
|
@@ -35,7 +35,7 @@ PROVIDERCONFIG = 'opentestfactory.org/v1beta1/ProviderConfig'
|
|
|
35
35
|
|
|
36
36
|
SUBSCRIPTION = 'opentestfactory.org/v1alpha1/Subscription'
|
|
37
37
|
|
|
38
|
-
WORKFLOW = 'opentestfactory.org/
|
|
38
|
+
WORKFLOW = 'opentestfactory.org/v1/Workflow'
|
|
39
39
|
WORKFLOWCOMPLETED = 'opentestfactory.org/v1alpha1/WorkflowCompleted'
|
|
40
40
|
WORKFLOWCANCELED = 'opentestfactory.org/v1alpha1/WorkflowCanceled'
|
|
41
41
|
WORKFLOWRESULT = 'opentestfactory.org/v1alpha1/WorkflowResult'
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2019-09/schema#",
|
|
3
|
+
"title": "JSON SCHEMA for opentestfactory.org/v1beta1 Workflow manifests",
|
|
4
|
+
"description": "An Orchestrator Workflow. Must have a name and at least one job.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"apiVersion": {
|
|
8
|
+
"enum": [
|
|
9
|
+
"opentestfactory.org/v1alpha1",
|
|
10
|
+
"opentestfactory.org/v1beta1",
|
|
11
|
+
"opentestfactory.org/v1"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"kind": {
|
|
15
|
+
"const": "Workflow"
|
|
16
|
+
},
|
|
17
|
+
"metadata": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"properties": {
|
|
20
|
+
"name": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"namespace": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"pattern": "^[a-z0-9][a-z0-9-]*$"
|
|
26
|
+
},
|
|
27
|
+
"labels": {
|
|
28
|
+
"type": "object",
|
|
29
|
+
"patternProperties": {
|
|
30
|
+
"^([a-zA-Z0-9-.]+/)?[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$": {
|
|
31
|
+
"type": "string"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"minProperties": 1,
|
|
35
|
+
"additionalProperties": false
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"additionalProperties": true,
|
|
39
|
+
"required": [
|
|
40
|
+
"name"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"defaults": {
|
|
44
|
+
"$ref": "#/definitions/defaults"
|
|
45
|
+
},
|
|
46
|
+
"variables": {
|
|
47
|
+
"$ref": "#/definitions/variables"
|
|
48
|
+
},
|
|
49
|
+
"secrets": {
|
|
50
|
+
"$ref": "#/definitions/secrets"
|
|
51
|
+
},
|
|
52
|
+
"timeout-minutes": {
|
|
53
|
+
"$ref": "#/definitions/number-expression"
|
|
54
|
+
},
|
|
55
|
+
"hooks": {
|
|
56
|
+
"type": "array",
|
|
57
|
+
"minItems": 1,
|
|
58
|
+
"items": {
|
|
59
|
+
"type": "object",
|
|
60
|
+
"properties": {
|
|
61
|
+
"name": {
|
|
62
|
+
"type": "string"
|
|
63
|
+
},
|
|
64
|
+
"if": {
|
|
65
|
+
"type": "string"
|
|
66
|
+
},
|
|
67
|
+
"events": {
|
|
68
|
+
"type": "array",
|
|
69
|
+
"minItems": 1
|
|
70
|
+
},
|
|
71
|
+
"before": {
|
|
72
|
+
"type": "array",
|
|
73
|
+
"minItems": 1
|
|
74
|
+
},
|
|
75
|
+
"after": {
|
|
76
|
+
"type": "array",
|
|
77
|
+
"minItems": 1
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"anyOf": [
|
|
81
|
+
{
|
|
82
|
+
"required": [
|
|
83
|
+
"name",
|
|
84
|
+
"events",
|
|
85
|
+
"before"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"required": [
|
|
90
|
+
"name",
|
|
91
|
+
"events",
|
|
92
|
+
"after",
|
|
93
|
+
"before"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"required": [
|
|
98
|
+
"name",
|
|
99
|
+
"events",
|
|
100
|
+
"after"
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"additionalProperties": false
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"resources": {
|
|
108
|
+
"type": "object",
|
|
109
|
+
"properties": {
|
|
110
|
+
"testmanagers": {
|
|
111
|
+
"type": "array",
|
|
112
|
+
"items": {
|
|
113
|
+
"type": "object",
|
|
114
|
+
"properties": {
|
|
115
|
+
"testmanager": {
|
|
116
|
+
"type": "string"
|
|
117
|
+
},
|
|
118
|
+
"type": {
|
|
119
|
+
"type": "string"
|
|
120
|
+
},
|
|
121
|
+
"name": {
|
|
122
|
+
"type": "string"
|
|
123
|
+
},
|
|
124
|
+
"endpoint": {
|
|
125
|
+
"type": "string"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"required": [
|
|
129
|
+
"testmanager",
|
|
130
|
+
"type",
|
|
131
|
+
"name",
|
|
132
|
+
"endpoint"
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"repositories": {
|
|
137
|
+
"type": "array",
|
|
138
|
+
"items": {
|
|
139
|
+
"type": "object",
|
|
140
|
+
"properties": {
|
|
141
|
+
"repository": {
|
|
142
|
+
"type": "string"
|
|
143
|
+
},
|
|
144
|
+
"type": {
|
|
145
|
+
"type": "string",
|
|
146
|
+
"pattern": "^[a-z][a-z0-9]*$"
|
|
147
|
+
},
|
|
148
|
+
"name": {
|
|
149
|
+
"type": "string"
|
|
150
|
+
},
|
|
151
|
+
"endpoint": {
|
|
152
|
+
"type": "string"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"required": [
|
|
156
|
+
"repository",
|
|
157
|
+
"type",
|
|
158
|
+
"name",
|
|
159
|
+
"endpoint"
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"files": {
|
|
164
|
+
"type": "array",
|
|
165
|
+
"items": {
|
|
166
|
+
"anyOf": [
|
|
167
|
+
{
|
|
168
|
+
"type": "string"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"type": "object",
|
|
172
|
+
"properties": {
|
|
173
|
+
"name": {
|
|
174
|
+
"type": "string"
|
|
175
|
+
},
|
|
176
|
+
"url": {
|
|
177
|
+
"type": "string"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"jobs": {
|
|
187
|
+
"type": "object",
|
|
188
|
+
"patternProperties": {
|
|
189
|
+
"^[a-zA-Z_][a-zA-Z0-9_-]*$": {
|
|
190
|
+
"oneOf": [
|
|
191
|
+
{
|
|
192
|
+
"$ref": "#/definitions/job_generator"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"$ref": "#/definitions/job_steps"
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
"minProperties": 1
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
"required": [
|
|
204
|
+
"metadata",
|
|
205
|
+
"jobs"
|
|
206
|
+
],
|
|
207
|
+
"additionalProperties": false,
|
|
208
|
+
"definitions": {
|
|
209
|
+
"defaults": {
|
|
210
|
+
"type": "object",
|
|
211
|
+
"propertyNames": {
|
|
212
|
+
"pattern": "^[a-zA-Z][a-zA-Z0-9-]*$"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"job_generator": {
|
|
216
|
+
"type": "object",
|
|
217
|
+
"properties": {
|
|
218
|
+
"name": {
|
|
219
|
+
"type": "string"
|
|
220
|
+
},
|
|
221
|
+
"if": {
|
|
222
|
+
"type": "string"
|
|
223
|
+
},
|
|
224
|
+
"needs": {
|
|
225
|
+
"$ref": "#/definitions/needs"
|
|
226
|
+
},
|
|
227
|
+
"variables": {
|
|
228
|
+
"$ref": "#/definitions/variables"
|
|
229
|
+
},
|
|
230
|
+
"defaults": {
|
|
231
|
+
"$ref": "#/definitions/defaults"
|
|
232
|
+
},
|
|
233
|
+
"runs-on": {
|
|
234
|
+
"$ref": "#/definitions/runs-on"
|
|
235
|
+
},
|
|
236
|
+
"strategy": {
|
|
237
|
+
"type": "object"
|
|
238
|
+
},
|
|
239
|
+
"outputs": {
|
|
240
|
+
"type": "object"
|
|
241
|
+
},
|
|
242
|
+
"timeout-minutes": {
|
|
243
|
+
"$ref": "#/definitions/number-expression"
|
|
244
|
+
},
|
|
245
|
+
"continue-on-error": {
|
|
246
|
+
"$ref": "#/definitions/boolean-expression"
|
|
247
|
+
},
|
|
248
|
+
"generator": {
|
|
249
|
+
"type": "string"
|
|
250
|
+
},
|
|
251
|
+
"with": {
|
|
252
|
+
"type": "object"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"required": [
|
|
256
|
+
"generator"
|
|
257
|
+
],
|
|
258
|
+
"additionalProperties": false
|
|
259
|
+
},
|
|
260
|
+
"job_steps": {
|
|
261
|
+
"type": "object",
|
|
262
|
+
"properties": {
|
|
263
|
+
"name": {
|
|
264
|
+
"type": "string"
|
|
265
|
+
},
|
|
266
|
+
"if": {
|
|
267
|
+
"type": "string"
|
|
268
|
+
},
|
|
269
|
+
"needs": {
|
|
270
|
+
"$ref": "#/definitions/needs"
|
|
271
|
+
},
|
|
272
|
+
"variables": {
|
|
273
|
+
"$ref": "#/definitions/variables"
|
|
274
|
+
},
|
|
275
|
+
"defaults": {
|
|
276
|
+
"$ref": "#/definitions/defaults"
|
|
277
|
+
},
|
|
278
|
+
"runs-on": {
|
|
279
|
+
"$ref": "#/definitions/runs-on"
|
|
280
|
+
},
|
|
281
|
+
"strategy": {
|
|
282
|
+
"type": "object"
|
|
283
|
+
},
|
|
284
|
+
"outputs": {
|
|
285
|
+
"type": "object"
|
|
286
|
+
},
|
|
287
|
+
"timeout-minutes": {
|
|
288
|
+
"$ref": "#/definitions/number-expression"
|
|
289
|
+
},
|
|
290
|
+
"continue-on-error": {
|
|
291
|
+
"$ref": "#/definitions/boolean-expression"
|
|
292
|
+
},
|
|
293
|
+
"steps": {
|
|
294
|
+
"type": "array",
|
|
295
|
+
"minItems": 1,
|
|
296
|
+
"items": {
|
|
297
|
+
"anyOf": [
|
|
298
|
+
{
|
|
299
|
+
"type": "object",
|
|
300
|
+
"properties": {
|
|
301
|
+
"name": {
|
|
302
|
+
"type": "string"
|
|
303
|
+
},
|
|
304
|
+
"id": {
|
|
305
|
+
"type": "string"
|
|
306
|
+
},
|
|
307
|
+
"if": {
|
|
308
|
+
"type": "string"
|
|
309
|
+
},
|
|
310
|
+
"uses": {
|
|
311
|
+
"type": "string"
|
|
312
|
+
},
|
|
313
|
+
"with": {
|
|
314
|
+
"type": "object"
|
|
315
|
+
},
|
|
316
|
+
"variables": {
|
|
317
|
+
"$ref": "#/definitions/variables"
|
|
318
|
+
},
|
|
319
|
+
"timeout-minutes": {
|
|
320
|
+
"$ref": "#/definitions/number-expression"
|
|
321
|
+
},
|
|
322
|
+
"continue-on-error": {
|
|
323
|
+
"$ref": "#/definitions/boolean-expression"
|
|
324
|
+
},
|
|
325
|
+
"working-directory": {
|
|
326
|
+
"type": "string"
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
"required": [
|
|
330
|
+
"uses"
|
|
331
|
+
],
|
|
332
|
+
"additionalProperties": false
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"type": "object",
|
|
336
|
+
"properties": {
|
|
337
|
+
"name": {
|
|
338
|
+
"type": "string"
|
|
339
|
+
},
|
|
340
|
+
"id": {
|
|
341
|
+
"type": "string"
|
|
342
|
+
},
|
|
343
|
+
"if": {
|
|
344
|
+
"type": "string"
|
|
345
|
+
},
|
|
346
|
+
"run": {
|
|
347
|
+
"type": "string"
|
|
348
|
+
},
|
|
349
|
+
"shell": {
|
|
350
|
+
"type": "string"
|
|
351
|
+
},
|
|
352
|
+
"variables": {
|
|
353
|
+
"$ref": "#/definitions/variables"
|
|
354
|
+
},
|
|
355
|
+
"timeout-minutes": {
|
|
356
|
+
"$ref": "#/definitions/number-expression"
|
|
357
|
+
},
|
|
358
|
+
"continue-on-error": {
|
|
359
|
+
"$ref": "#/definitions/boolean-expression"
|
|
360
|
+
},
|
|
361
|
+
"working-directory": {
|
|
362
|
+
"type": "string"
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
"required": [
|
|
366
|
+
"run"
|
|
367
|
+
],
|
|
368
|
+
"additionalProperties": false
|
|
369
|
+
}
|
|
370
|
+
]
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
"required": [
|
|
375
|
+
"steps"
|
|
376
|
+
],
|
|
377
|
+
"additionalProperties": false
|
|
378
|
+
},
|
|
379
|
+
"needs": {
|
|
380
|
+
"anyOf": [
|
|
381
|
+
{
|
|
382
|
+
"type": "string",
|
|
383
|
+
"pattern": "(^[a-zA-Z_][a-zA-Z0-9_-]*$)|(^\\$\\{\\{.*\\}\\}$)"
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
"type": "array",
|
|
387
|
+
"items": {
|
|
388
|
+
"type": "string",
|
|
389
|
+
"pattern": "(^[a-zA-Z_][a-zA-Z0-9_-]*$)|(^\\$\\{\\{.*\\}\\}$)"
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
]
|
|
393
|
+
},
|
|
394
|
+
"number-expression": {
|
|
395
|
+
"anyOf": [
|
|
396
|
+
{
|
|
397
|
+
"type": "number"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
"type": "string",
|
|
401
|
+
"pattern": "^\\$\\{\\{.*\\}\\}$"
|
|
402
|
+
}
|
|
403
|
+
]
|
|
404
|
+
},
|
|
405
|
+
"boolean-expression": {
|
|
406
|
+
"anyOf": [
|
|
407
|
+
{
|
|
408
|
+
"type": "boolean"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"type": "string",
|
|
412
|
+
"pattern": "^\\$\\{\\{.*\\}\\}$"
|
|
413
|
+
}
|
|
414
|
+
]
|
|
415
|
+
},
|
|
416
|
+
"runs-on": {
|
|
417
|
+
"anyOf": [
|
|
418
|
+
{
|
|
419
|
+
"type": "string",
|
|
420
|
+
"pattern": "(^[a-zA-Z][a-zA-Z0-9-]*$)|(^\\$\\{\\{.*\\}\\}$)"
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"type": "array",
|
|
424
|
+
"items": {
|
|
425
|
+
"type": "string",
|
|
426
|
+
"pattern": "(^[a-zA-Z][a-zA-Z0-9-]*$)|(^\\$\\{\\{.*\\}\\}$)"
|
|
427
|
+
},
|
|
428
|
+
"minItems": 1
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
"type": "object"
|
|
432
|
+
}
|
|
433
|
+
]
|
|
434
|
+
},
|
|
435
|
+
"variables": {
|
|
436
|
+
"type": "object",
|
|
437
|
+
"patternProperties": {
|
|
438
|
+
"^[a-zA-Z0-9_]+$": {
|
|
439
|
+
"oneOf": [
|
|
440
|
+
{
|
|
441
|
+
"type": "string"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
"type": "object",
|
|
445
|
+
"properties": {
|
|
446
|
+
"value": {
|
|
447
|
+
"type": "string"
|
|
448
|
+
},
|
|
449
|
+
"verbatim": {
|
|
450
|
+
"type": "boolean"
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
"required": [
|
|
454
|
+
"value"
|
|
455
|
+
],
|
|
456
|
+
"additionalProperties": false
|
|
457
|
+
}
|
|
458
|
+
]
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
"minProperties": 1
|
|
462
|
+
},
|
|
463
|
+
"secrets": {
|
|
464
|
+
"type": "object",
|
|
465
|
+
"patternProperties": {
|
|
466
|
+
"^[a-zA-Z0-9_]+$": {
|
|
467
|
+
"type": "string"
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
"minProperties": 1
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
opentf/toolkit/__init__.py
CHANGED
|
@@ -296,6 +296,17 @@ def _dispatch_executioncommand(_, handler: Handler, body: Dict[str, Any]):
|
|
|
296
296
|
return make_status_response('InternalError', msg)
|
|
297
297
|
|
|
298
298
|
|
|
299
|
+
def _dispatch_generatorcommand(_, handler: Handler, body: Dict[str, Any]):
|
|
300
|
+
"""Generator plugin dispatcher."""
|
|
301
|
+
try:
|
|
302
|
+
inputs: Dict[str, Any] = body.get('with', {})
|
|
303
|
+
core.publish_generatorresult(handler(inputs))
|
|
304
|
+
except Exception as err:
|
|
305
|
+
msg = f'Unexpected execution error: {err}.'
|
|
306
|
+
core.publish_error(msg)
|
|
307
|
+
return make_status_response('InternalError', msg)
|
|
308
|
+
|
|
309
|
+
|
|
299
310
|
########################################################################
|
|
300
311
|
# Watchdog
|
|
301
312
|
|
|
@@ -476,6 +487,37 @@ def run_plugin(plugin):
|
|
|
476
487
|
context[SUBSCRIPTION_KEY].append(
|
|
477
488
|
subscribe(kind=EXECUTIONCOMMAND, target='inbox', app=plugin)
|
|
478
489
|
)
|
|
490
|
+
elif context[KIND_KEY] == GENERATORCOMMAND:
|
|
491
|
+
for manifest in plugin.config['DESCRIPTOR']:
|
|
492
|
+
metadata = manifest.get('metadata', {})
|
|
493
|
+
if metadata.get('name', '').lower() != plugin.name.lower():
|
|
494
|
+
continue
|
|
495
|
+
if 'action' not in metadata:
|
|
496
|
+
continue
|
|
497
|
+
for event in manifest.get('events', []):
|
|
498
|
+
cat_prefix = event.get('categoryPrefix')
|
|
499
|
+
cat = event.get('category')
|
|
500
|
+
if cat or cat_prefix:
|
|
501
|
+
cat_version = event.get('categoryVersion')
|
|
502
|
+
labels = {}
|
|
503
|
+
if cat is not None:
|
|
504
|
+
labels['opentestfactory.org/category'] = cat
|
|
505
|
+
if cat_prefix is not None:
|
|
506
|
+
labels['opentestfactory.org/categoryPrefix'] = cat_prefix
|
|
507
|
+
if cat_version is not None:
|
|
508
|
+
labels['opentestfactory.org/categoryVersion'] = cat_version
|
|
509
|
+
context[SUBSCRIPTION_KEY].append(
|
|
510
|
+
subscribe(
|
|
511
|
+
kind=GENERATORCOMMAND,
|
|
512
|
+
target='inbox',
|
|
513
|
+
labels=labels,
|
|
514
|
+
app=plugin,
|
|
515
|
+
)
|
|
516
|
+
)
|
|
517
|
+
else:
|
|
518
|
+
plugin.logger.warning(
|
|
519
|
+
"At least one of 'category', 'categoryPrefix' required, ignoring."
|
|
520
|
+
)
|
|
479
521
|
run_app(plugin)
|
|
480
522
|
finally:
|
|
481
523
|
for subscription_id in plugin.config['CONTEXT'][SUBSCRIPTION_KEY]:
|
|
@@ -558,6 +600,8 @@ def make_plugin(
|
|
|
558
600
|
_dispatch_providercommand(plugin, provider, body)
|
|
559
601
|
elif channel:
|
|
560
602
|
return _dispatch_executioncommand(plugin, channel, body)
|
|
603
|
+
elif generator:
|
|
604
|
+
_dispatch_generatorcommand(plugin, generator, body)
|
|
561
605
|
else:
|
|
562
606
|
return make_status_response('BadRequest', 'Not implemented yet.')
|
|
563
607
|
|
opentf/toolkit/core.py
CHANGED
|
@@ -24,6 +24,7 @@ import posixpath
|
|
|
24
24
|
import sys
|
|
25
25
|
|
|
26
26
|
from opentf.commons import (
|
|
27
|
+
GENERATORRESULT,
|
|
27
28
|
PROVIDERRESULT,
|
|
28
29
|
EXECUTIONERROR,
|
|
29
30
|
publish,
|
|
@@ -140,6 +141,16 @@ def publish_providerresult(steps: Iterable) -> None:
|
|
|
140
141
|
publish_event(command)
|
|
141
142
|
|
|
142
143
|
|
|
144
|
+
def publish_generatorresult(jobs: Dict[str, Any]) -> None:
|
|
145
|
+
"""Publish GeneratorResult event."""
|
|
146
|
+
command = make_event(
|
|
147
|
+
GENERATORRESULT,
|
|
148
|
+
metadata=_getbody()['metadata'],
|
|
149
|
+
jobs={k: v.copy() for k, v in jobs.items()},
|
|
150
|
+
)
|
|
151
|
+
publish_event(command)
|
|
152
|
+
|
|
153
|
+
|
|
143
154
|
########################################################################
|
|
144
155
|
## Toolkit helpers
|
|
145
156
|
|
|
@@ -2,12 +2,13 @@ opentf/commons/__init__.py,sha256=KRY8ShQw_0ZZ0oEOiKi4-xnWofE_QsFjEe1T8wUxJ-w,21
|
|
|
2
2
|
opentf/commons/auth.py,sha256=bM2Z3kxm2Wku1lKXaRAIg37LHvXWAXIZIqjplDfN2P8,15899
|
|
3
3
|
opentf/commons/config.py,sha256=GmvInVnUsXIwlNfgTQeQ_pPs97GeGTGn2S2QZEFwss8,7828
|
|
4
4
|
opentf/commons/datasources.py,sha256=4ye-TMtaE88O8GVcWx-FtKXOC8aIZLteR6wfIr7Do8U,25232
|
|
5
|
-
opentf/commons/expressions.py,sha256=
|
|
5
|
+
opentf/commons/expressions.py,sha256=973wiKlM0jcKf4nQpVRtZ7F0-ORHQn1TY_4rVGtNZXc,20007
|
|
6
6
|
opentf/commons/pubsub.py,sha256=7khxAHVZiwJRcwIBJ6MPR-f3xY9144-2eNLROwq5F-4,5894
|
|
7
|
-
opentf/commons/schemas.py,sha256=
|
|
7
|
+
opentf/commons/schemas.py,sha256=YSCvlmqc7satt-OqIoYXnmhOyo9h8wIpNyKaBAY4u9c,4039
|
|
8
8
|
opentf/commons/selectors.py,sha256=DEpLgRAr5HXSpSYI4liXP2hLUTvOSexFa9Vfa1xIQTk,7134
|
|
9
9
|
opentf/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
opentf/schemas/abac.opentestfactory.org/v1alpha1/Policy.json,sha256=JXsfNAPSEYggeyaDutSQBeG38o4Bmcr70dPLWWeqIh8,2105
|
|
11
|
+
opentf/schemas/opentestfactory.org/v1/Workflow.json,sha256=tzBM38Q-XGzz0NS96JxgQR2CwS1_e7BaHjFvwunjqfM,16050
|
|
11
12
|
opentf/schemas/opentestfactory.org/v1alpha1/AgentRegistration.json,sha256=NQykqU-lKE8LtBhBiFUcpVJq00MRG6dZsoM1xedx6uQ,1230
|
|
12
13
|
opentf/schemas/opentestfactory.org/v1alpha1/AllureCollectorOutput.json,sha256=-L9DDWA0A4x54bPMn4m6Qwi2tf2nHvzIPFOElTjaVck,1366
|
|
13
14
|
opentf/schemas/opentestfactory.org/v1alpha1/ChannelHandlerHooks.json,sha256=6K6m9praw_f2biCMHfTsHPYia5z2jq10dciRLqf3ogI,1239
|
|
@@ -45,11 +46,11 @@ opentf/schemas/opentestfactory.org/v1beta1/Workflow.json,sha256=QZ8mM9PhzsI9gTmw
|
|
|
45
46
|
opentf/schemas/opentestfactory.org/v1beta2/ServiceConfig.json,sha256=rEvK2YWL5lG94_qYgR_GnLWNsaQhaQ-2kuZdWJr5NnY,3517
|
|
46
47
|
opentf/scripts/launch_java_service.sh,sha256=S0jAaCuv2sZy0Gf2NGBuPX-eD531rcM-b0fNyhmzSjw,2423
|
|
47
48
|
opentf/scripts/startup.py,sha256=Da2zo93pBWbdRmj-wgekgLcF94rpNc3ZkbvR8R0w8XY,21279
|
|
48
|
-
opentf/toolkit/__init__.py,sha256=
|
|
49
|
+
opentf/toolkit/__init__.py,sha256=icNo_jz2IfhwddunQpfq6F-0xeKS70S-0Or5zJliEZs,21692
|
|
49
50
|
opentf/toolkit/channels.py,sha256=Cng3b4LUsxvCHUbp_skys9CFcKZMfcKhA_ODg_EAlIE,17156
|
|
50
|
-
opentf/toolkit/core.py,sha256=
|
|
51
|
-
opentf_toolkit_nightly-0.56.0.
|
|
52
|
-
opentf_toolkit_nightly-0.56.0.
|
|
53
|
-
opentf_toolkit_nightly-0.56.0.
|
|
54
|
-
opentf_toolkit_nightly-0.56.0.
|
|
55
|
-
opentf_toolkit_nightly-0.56.0.
|
|
51
|
+
opentf/toolkit/core.py,sha256=MvvWUrS4dvo3Qrd_Yl9uND3CllL0qtMi-y1S-Na1uQs,9621
|
|
52
|
+
opentf_toolkit_nightly-0.56.0.dev994.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
53
|
+
opentf_toolkit_nightly-0.56.0.dev994.dist-info/METADATA,sha256=k30Un4fXbpz1LANg28R6ax4_WvALNaA9HQD58mvGd6M,1945
|
|
54
|
+
opentf_toolkit_nightly-0.56.0.dev994.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
55
|
+
opentf_toolkit_nightly-0.56.0.dev994.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
|
|
56
|
+
opentf_toolkit_nightly-0.56.0.dev994.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|