opentf-toolkit-nightly 0.58.0.dev1149__py3-none-any.whl → 0.58.0.dev1159__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/__init__.py +3 -0
- opentf/toolkit/channels.py +60 -6
- {opentf_toolkit_nightly-0.58.0.dev1149.dist-info → opentf_toolkit_nightly-0.58.0.dev1159.dist-info}/METADATA +9 -9
- {opentf_toolkit_nightly-0.58.0.dev1149.dist-info → opentf_toolkit_nightly-0.58.0.dev1159.dist-info}/RECORD +7 -7
- {opentf_toolkit_nightly-0.58.0.dev1149.dist-info → opentf_toolkit_nightly-0.58.0.dev1159.dist-info}/WHEEL +1 -1
- {opentf_toolkit_nightly-0.58.0.dev1149.dist-info → opentf_toolkit_nightly-0.58.0.dev1159.dist-info}/LICENSE +0 -0
- {opentf_toolkit_nightly-0.58.0.dev1149.dist-info → opentf_toolkit_nightly-0.58.0.dev1159.dist-info}/top_level.txt +0 -0
opentf/commons/__init__.py
CHANGED
|
@@ -157,6 +157,9 @@ def _check_token(authz: str, context: Dict[str, Any]) -> Optional[Response]:
|
|
|
157
157
|
except ValueError as err:
|
|
158
158
|
logging.error('Invalid trusted key #%d:', i)
|
|
159
159
|
logging.error(err)
|
|
160
|
+
except jwt.InvalidKeyError as err:
|
|
161
|
+
logging.error('Invalid trusted key #%d:', i)
|
|
162
|
+
logging.error(err)
|
|
160
163
|
except jwt.InvalidAlgorithmError as err:
|
|
161
164
|
logging.error(
|
|
162
165
|
'Invalid algorithm while verifying token by trusted key #%d:', i
|
opentf/toolkit/channels.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2021 Henix, Henix.fr
|
|
1
|
+
# Copyright (c) 2021-2024 Henix, Henix.fr
|
|
2
2
|
#
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
# you may not use this file except in compliance with the License.
|
|
@@ -23,13 +23,19 @@ import ntpath
|
|
|
23
23
|
import os
|
|
24
24
|
import re
|
|
25
25
|
|
|
26
|
-
from opentf.commons import
|
|
26
|
+
from opentf.commons import (
|
|
27
|
+
EXECUTIONRESULT,
|
|
28
|
+
WORKFLOWRESULT,
|
|
29
|
+
make_event,
|
|
30
|
+
make_uuid,
|
|
31
|
+
)
|
|
27
32
|
from opentf.toolkit import core
|
|
28
33
|
|
|
29
34
|
## workflow commands
|
|
30
35
|
|
|
31
36
|
SETOUTPUT_COMMAND = re.compile(r'^::set-output\s+name=([a-zA-Z_][a-zA-Z0-9_-]*)::(.*)$')
|
|
32
37
|
ATTACH_COMMAND = re.compile(r'^::attach(\s+.*?)?::(.*?)\s*$')
|
|
38
|
+
UPLOAD_COMMAND = re.compile(r'^::upload(\s+.*?)?::(.*?)\s*$')
|
|
33
39
|
DEBUG_COMMAND = re.compile(r'^::debug::(.*)$')
|
|
34
40
|
WARNING_COMMAND = re.compile(r'^::warning(\s+(.*)+)?::(.*)$')
|
|
35
41
|
ERROR_COMMAND = re.compile(r'^::error(\s+(.*)+)?::(.*)$')
|
|
@@ -174,10 +180,12 @@ def _add_default_variables(
|
|
|
174
180
|
|
|
175
181
|
|
|
176
182
|
def _make_attachment_url(
|
|
177
|
-
metadata: Dict[str, Any], remote: str, separator: str
|
|
183
|
+
metadata: Dict[str, Any], remote: str, separator: str, workflow_result: bool = False
|
|
178
184
|
) -> Tuple[str, Dict[str, Any]]:
|
|
179
185
|
uuid = make_uuid()
|
|
180
|
-
|
|
186
|
+
prefix = metadata['workflow_id'] if workflow_result else metadata['job_id']
|
|
187
|
+
suffix = 'WR' if workflow_result else metadata['step_sequence_id']
|
|
188
|
+
url = f'/tmp/{prefix}-{uuid}_{suffix}_{remote.split(separator)[-1]}'
|
|
181
189
|
return url, {'uuid': uuid}
|
|
182
190
|
|
|
183
191
|
|
|
@@ -207,6 +215,43 @@ def _as_log(line: str, jobstate: JobState):
|
|
|
207
215
|
return mask(line, jobstate).rstrip()
|
|
208
216
|
|
|
209
217
|
|
|
218
|
+
def process_upload(result: Dict[str, Any]):
|
|
219
|
+
"""Process ExecutionResult event containing .metadata.upload flag.
|
|
220
|
+
|
|
221
|
+
Dispatch attachments between ExecutionResult and WorkflowResult events,
|
|
222
|
+
publish WorkflowResult.
|
|
223
|
+
"""
|
|
224
|
+
|
|
225
|
+
def _filter_items(key: str):
|
|
226
|
+
metadata = {}
|
|
227
|
+
items = [item for item in result['attachments'] if item[pos:].startswith(key)]
|
|
228
|
+
if items:
|
|
229
|
+
metadata = {
|
|
230
|
+
k: v for k, v in result['metadata']['attachments'].items() if k in items
|
|
231
|
+
}
|
|
232
|
+
return items, metadata
|
|
233
|
+
|
|
234
|
+
del result['metadata']['upload']
|
|
235
|
+
pos = len('/tmp/')
|
|
236
|
+
upload, upload_metadata = _filter_items(result['metadata']['workflow_id'])
|
|
237
|
+
attach, attach_metadata = _filter_items(result['metadata']['job_id'])
|
|
238
|
+
|
|
239
|
+
if attach:
|
|
240
|
+
result['attachments'] = attach
|
|
241
|
+
result['metadata']['attachments'] = attach_metadata
|
|
242
|
+
else:
|
|
243
|
+
del result['attachments']
|
|
244
|
+
del result['metadata']['attachments']
|
|
245
|
+
|
|
246
|
+
metadata = {
|
|
247
|
+
'attachments': upload_metadata,
|
|
248
|
+
'name': result['metadata'].get('step_id'),
|
|
249
|
+
'namespace': result['metadata']['namespace'],
|
|
250
|
+
'workflow_id': result['metadata']['workflow_id'],
|
|
251
|
+
}
|
|
252
|
+
return make_event(WORKFLOWRESULT, metadata=metadata, attachments=upload)
|
|
253
|
+
|
|
254
|
+
|
|
210
255
|
def process_output(
|
|
211
256
|
event: Dict[str, Any],
|
|
212
257
|
resp: int,
|
|
@@ -225,6 +270,7 @@ def process_output(
|
|
|
225
270
|
- stdout: a list of strings
|
|
226
271
|
- stderr: a list of strings
|
|
227
272
|
- jobstate: a JobState object
|
|
273
|
+
- context: a dictionary, channelhandler context
|
|
228
274
|
- attach: a function copying a remote file to a local path
|
|
229
275
|
- put: a function copying a local file to a remote environment
|
|
230
276
|
|
|
@@ -253,7 +299,9 @@ def process_output(
|
|
|
253
299
|
if is_windows:
|
|
254
300
|
remote = ntpath.normpath(remote)
|
|
255
301
|
try:
|
|
256
|
-
attachment_url, details = _make_attachment_url(
|
|
302
|
+
attachment_url, details = _make_attachment_url(
|
|
303
|
+
metadata, remote, separator, upload
|
|
304
|
+
)
|
|
257
305
|
if args:
|
|
258
306
|
for parameter in args.strip().split(','):
|
|
259
307
|
if '=' not in parameter:
|
|
@@ -299,6 +347,7 @@ def process_output(
|
|
|
299
347
|
attachments: List[str] = []
|
|
300
348
|
attachments_metadata = {}
|
|
301
349
|
|
|
350
|
+
upload = False
|
|
302
351
|
for line in stdout:
|
|
303
352
|
# Parsing stdout for workflow commands
|
|
304
353
|
if jobstate.stop_command:
|
|
@@ -308,6 +357,9 @@ def process_output(
|
|
|
308
357
|
|
|
309
358
|
if wcmd := ATTACH_COMMAND.match(line):
|
|
310
359
|
resp = _attach(wcmd.group(2), wcmd.group(1))
|
|
360
|
+
elif wcmd := UPLOAD_COMMAND.match(line):
|
|
361
|
+
upload = True
|
|
362
|
+
resp = _attach(wcmd.group(2), wcmd.group(1))
|
|
311
363
|
elif wcmd := PUT_FILE_COMMAND.match(line):
|
|
312
364
|
resp = _putfile(wcmd.group(2), wcmd.group(1))
|
|
313
365
|
elif wcmd := SETOUTPUT_COMMAND.match(line):
|
|
@@ -323,6 +375,7 @@ def process_output(
|
|
|
323
375
|
logs.append(mask(line, jobstate).rstrip())
|
|
324
376
|
|
|
325
377
|
result = make_event(EXECUTIONRESULT, metadata=metadata, status=resp)
|
|
378
|
+
|
|
326
379
|
if outputs:
|
|
327
380
|
result['outputs'] = outputs
|
|
328
381
|
if logs:
|
|
@@ -330,7 +383,8 @@ def process_output(
|
|
|
330
383
|
if attachments:
|
|
331
384
|
result['attachments'] = attachments
|
|
332
385
|
result['metadata']['attachments'] = attachments_metadata
|
|
333
|
-
|
|
386
|
+
if upload:
|
|
387
|
+
result['metadata']['upload'] = resp
|
|
334
388
|
return result
|
|
335
389
|
|
|
336
390
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: opentf-toolkit-nightly
|
|
3
|
-
Version: 0.58.0.
|
|
3
|
+
Version: 0.58.0.dev1159
|
|
4
4
|
Summary: OpenTestFactory Orchestrator Toolkit
|
|
5
5
|
Home-page: https://gitlab.com/henixdevelopment/open-source/opentestfactory/python-toolkit
|
|
6
6
|
Author: Martin Lafaix
|
|
@@ -16,14 +16,14 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
16
16
|
Requires-Python: >= 3.9.0
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
License-File: LICENSE
|
|
19
|
-
Requires-Dist: requests>=2.32
|
|
20
|
-
Requires-Dist: PyJWT[crypto]
|
|
21
|
-
Requires-Dist: PyYAML>=6
|
|
22
|
-
Requires-Dist: Flask<4,>=3
|
|
23
|
-
Requires-Dist: jsonschema>=4.23
|
|
24
|
-
Requires-Dist: toposort>=1.10
|
|
25
|
-
Requires-Dist: waitress>=3
|
|
26
|
-
Requires-Dist: paste>=3.10
|
|
19
|
+
Requires-Dist: requests >=2.32
|
|
20
|
+
Requires-Dist: PyJWT[crypto] >=2.9
|
|
21
|
+
Requires-Dist: PyYAML >=6
|
|
22
|
+
Requires-Dist: Flask <4,>=3
|
|
23
|
+
Requires-Dist: jsonschema >=4.23
|
|
24
|
+
Requires-Dist: toposort >=1.10
|
|
25
|
+
Requires-Dist: waitress >=3
|
|
26
|
+
Requires-Dist: paste >=3.10
|
|
27
27
|
|
|
28
28
|
# opentf-toolkit
|
|
29
29
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
opentf/commons/__init__.py,sha256=
|
|
1
|
+
opentf/commons/__init__.py,sha256=CecEYGl7HK5sBSGHeyPr-DaZN2_GQMKqVidS4e3sR8s,22636
|
|
2
2
|
opentf/commons/auth.py,sha256=bM2Z3kxm2Wku1lKXaRAIg37LHvXWAXIZIqjplDfN2P8,15899
|
|
3
3
|
opentf/commons/config.py,sha256=dyus4K5Zdmcftc3Y9Z1YRkzA1KwiRLHoeAlg2_A49QM,7876
|
|
4
4
|
opentf/commons/datasources.py,sha256=GSbjrYnZQup2B3r7T7l3C_o6R2jS13nQiu6dRitoenk,26194
|
|
@@ -55,10 +55,10 @@ opentf/schemas/opentestfactory.org/v1beta2/ServiceConfig.json,sha256=rEvK2YWL5lG
|
|
|
55
55
|
opentf/scripts/launch_java_service.sh,sha256=S0jAaCuv2sZy0Gf2NGBuPX-eD531rcM-b0fNyhmzSjw,2423
|
|
56
56
|
opentf/scripts/startup.py,sha256=c5fhYUy_Nk6z-eo0kW0mG56452dcIw9mzb9trljZYZ4,21453
|
|
57
57
|
opentf/toolkit/__init__.py,sha256=mYeJPZ92ulbTBItqEsZgF4nnuRh6G19QPY3Jxc92ifc,23028
|
|
58
|
-
opentf/toolkit/channels.py,sha256=
|
|
58
|
+
opentf/toolkit/channels.py,sha256=bAUo0FRNljkjgTkWqSJljsNeMSX21LLLZP-TS4cw1oo,18996
|
|
59
59
|
opentf/toolkit/core.py,sha256=6nud1vqcfjs9swZu_Z-rbvdbejtrlSjOd8eZXIF0ChE,9795
|
|
60
|
-
opentf_toolkit_nightly-0.58.0.
|
|
61
|
-
opentf_toolkit_nightly-0.58.0.
|
|
62
|
-
opentf_toolkit_nightly-0.58.0.
|
|
63
|
-
opentf_toolkit_nightly-0.58.0.
|
|
64
|
-
opentf_toolkit_nightly-0.58.0.
|
|
60
|
+
opentf_toolkit_nightly-0.58.0.dev1159.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
61
|
+
opentf_toolkit_nightly-0.58.0.dev1159.dist-info/METADATA,sha256=lSM8fNhAWfNcilR8k_1NoQdtn6kuSQrrksoRdn3D9w0,1940
|
|
62
|
+
opentf_toolkit_nightly-0.58.0.dev1159.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
63
|
+
opentf_toolkit_nightly-0.58.0.dev1159.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
|
|
64
|
+
opentf_toolkit_nightly-0.58.0.dev1159.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|