opentf-toolkit-nightly 0.63.0.dev1397__py3-none-any.whl → 0.63.0.dev1406__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/scripts/startup.py +15 -14
- opentf/toolkit/channels.py +37 -2
- {opentf_toolkit_nightly-0.63.0.dev1397.dist-info → opentf_toolkit_nightly-0.63.0.dev1406.dist-info}/METADATA +1 -1
- {opentf_toolkit_nightly-0.63.0.dev1397.dist-info → opentf_toolkit_nightly-0.63.0.dev1406.dist-info}/RECORD +7 -7
- {opentf_toolkit_nightly-0.63.0.dev1397.dist-info → opentf_toolkit_nightly-0.63.0.dev1406.dist-info}/WHEEL +1 -1
- {opentf_toolkit_nightly-0.63.0.dev1397.dist-info → opentf_toolkit_nightly-0.63.0.dev1406.dist-info}/licenses/LICENSE +0 -0
- {opentf_toolkit_nightly-0.63.0.dev1397.dist-info → opentf_toolkit_nightly-0.63.0.dev1406.dist-info}/top_level.txt +0 -0
opentf/scripts/startup.py
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
"""Startup script for allinone images."""
|
|
16
16
|
|
|
17
|
-
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
17
|
+
from typing import Any, Dict, List, Optional, Set, Tuple, Union
|
|
18
18
|
|
|
19
19
|
from datetime import datetime
|
|
20
20
|
from importlib.metadata import version
|
|
@@ -64,6 +64,7 @@ ENVIRONMENT_VARIABLES = {
|
|
|
64
64
|
'OPENTF_BASE_URL': None,
|
|
65
65
|
'OPENTF_CONTEXT': 'allinone',
|
|
66
66
|
'OPENTF_DEBUG': 'INFO',
|
|
67
|
+
'OPENTF_DISABLED_PLUGINS': None,
|
|
67
68
|
'OPENTF_EVENTBUS_WARMUPDELAY': 2,
|
|
68
69
|
'OPENTF_EVENTBUS_WARMUPURL': 'http://127.0.0.1:38368/subscriptions',
|
|
69
70
|
'OPENTF_EVENTBUSCONFIG': 'conf/eventbus.yaml',
|
|
@@ -220,7 +221,7 @@ SERVICES = set()
|
|
|
220
221
|
|
|
221
222
|
|
|
222
223
|
def parse_and_start(
|
|
223
|
-
paths: List[str], item: str, disabled: Optional[
|
|
224
|
+
paths: List[str], item: str, disabled: Optional[Set[str]] = None
|
|
224
225
|
) -> List[Any]:
|
|
225
226
|
"""Lookup item manifests and start them if not disabled."""
|
|
226
227
|
result = []
|
|
@@ -301,7 +302,7 @@ def maybe_start_otelcol():
|
|
|
301
302
|
else ''
|
|
302
303
|
)
|
|
303
304
|
cmd = '"/usr/local/bin/otelcol --config=file:/app/otelcol-config.yaml $OTELCOL_EXTRA_OPTIONS"'
|
|
304
|
-
logging.info(
|
|
305
|
+
logging.info('Starting OpenTelemetry Collector%s...', options_msg)
|
|
305
306
|
pid = subprocess.Popen(f'sh -c {cmd}', shell=True)
|
|
306
307
|
logging.debug('(pid is %d.)', pid.pid)
|
|
307
308
|
return [pid]
|
|
@@ -389,17 +390,17 @@ def start_services(conf: Dict[str, Any]) -> List[Any]:
|
|
|
389
390
|
|
|
390
391
|
def start_plugins(conf: Dict[str, Any]) -> List[Any]:
|
|
391
392
|
"""Lookup plugins and start them."""
|
|
392
|
-
|
|
393
|
-
disabled = [plugin.lower() for plugin in disabled]
|
|
394
|
-
else:
|
|
395
|
-
disabled = []
|
|
393
|
+
disabled = set(conf.get('disabled', {}))
|
|
396
394
|
if (v := _get_env('OPENTF_ALLURE_ENABLED')) is None or (
|
|
397
395
|
v.lower() not in ('true', 'yes', 'on', '1')
|
|
398
396
|
):
|
|
399
|
-
disabled.
|
|
400
|
-
disabled.
|
|
397
|
+
disabled.add('allure.collector')
|
|
398
|
+
disabled.add('result.aggregator')
|
|
399
|
+
if v := _get_env('OPENTF_DISABLED_PLUGINS'):
|
|
400
|
+
disabled |= set(v.split(','))
|
|
401
401
|
if aggregated := conf.get('aggregated'):
|
|
402
|
-
disabled
|
|
402
|
+
disabled |= set(aggregated)
|
|
403
|
+
disabled = {plugin.strip().lower() for plugin in disabled if plugin.strip()}
|
|
403
404
|
plugins = []
|
|
404
405
|
for entry in conf['plugins']:
|
|
405
406
|
plugins += parse_and_start(_expand(entry), PLUGIN_DESCRIPTOR, disabled)
|
|
@@ -523,10 +524,10 @@ def _ensure_abac_if_defined(name, value):
|
|
|
523
524
|
if value:
|
|
524
525
|
if not OPENTF_AUTHORIZATION_MODE:
|
|
525
526
|
logging.error(
|
|
526
|
-
'
|
|
527
|
-
' OPENTF_AUTHORIZATION_MODE must include "ABAC" to use
|
|
528
|
-
|
|
529
|
-
|
|
527
|
+
'%s is defined but OPENTF_AUTHORIZATION_MODE is undefined.'
|
|
528
|
+
' OPENTF_AUTHORIZATION_MODE must include "ABAC" to use %s.',
|
|
529
|
+
name,
|
|
530
|
+
name,
|
|
530
531
|
)
|
|
531
532
|
sys.exit(1)
|
|
532
533
|
if 'ABAC' not in OPENTF_AUTHORIZATION_MODE.split(','):
|
opentf/toolkit/channels.py
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
|
|
18
18
|
from typing import Any, Callable, Dict, List, NamedTuple, Optional, Set, Tuple, Union
|
|
19
19
|
|
|
20
|
+
from collections import defaultdict
|
|
21
|
+
from copy import deepcopy
|
|
20
22
|
from datetime import datetime
|
|
21
23
|
from shlex import quote
|
|
22
24
|
|
|
@@ -46,6 +48,14 @@ STOPCOMMANDS_COMMAND = re.compile(r'^::stop-commands::(\w+)$')
|
|
|
46
48
|
ADDMASK_COMMAND = re.compile(r'^::add-mask::(.*)$')
|
|
47
49
|
PUT_FILE_COMMAND = re.compile(r'^::put\s+file=(.*?)\s*::(.*?)\s*$')
|
|
48
50
|
|
|
51
|
+
COMMAND_PATTERNS = (
|
|
52
|
+
ATTACH_COMMAND,
|
|
53
|
+
UPLOAD_COMMAND,
|
|
54
|
+
DOWNLOAD_COMMAND,
|
|
55
|
+
PUT_FILE_COMMAND,
|
|
56
|
+
SETOUTPUT_COMMAND,
|
|
57
|
+
)
|
|
58
|
+
|
|
49
59
|
|
|
50
60
|
## step sequence IDs
|
|
51
61
|
|
|
@@ -313,6 +323,7 @@ class JobState:
|
|
|
313
323
|
def __init__(self) -> None:
|
|
314
324
|
self.stop_command: Optional[str] = None
|
|
315
325
|
self.masks: List[str] = []
|
|
326
|
+
self.workflow_commands: List[str] = []
|
|
316
327
|
|
|
317
328
|
|
|
318
329
|
def mask(line: str, state: JobState) -> str:
|
|
@@ -332,6 +343,9 @@ def _as_log(line: str, jobstate: JobState):
|
|
|
332
343
|
return mask(line, jobstate).rstrip()
|
|
333
344
|
|
|
334
345
|
|
|
346
|
+
## artifacts
|
|
347
|
+
|
|
348
|
+
|
|
335
349
|
def process_upload(result: Dict[str, Any]) -> Dict[str, Any]:
|
|
336
350
|
"""Process ExecutionResult event containing .metadata.upload flag.
|
|
337
351
|
|
|
@@ -427,7 +441,7 @@ def _download_artifacts(
|
|
|
427
441
|
|
|
428
442
|
def process_output(
|
|
429
443
|
event: Dict[str, Any],
|
|
430
|
-
resp: int,
|
|
444
|
+
resp: Optional[int],
|
|
431
445
|
stdout: List[str],
|
|
432
446
|
stderr: List[str],
|
|
433
447
|
jobstate: JobState,
|
|
@@ -540,6 +554,14 @@ def process_output(
|
|
|
540
554
|
attachments: List[str] = []
|
|
541
555
|
attachments_metadata = {}
|
|
542
556
|
|
|
557
|
+
is_channel_notify = False
|
|
558
|
+
step_sequence_id = metadata['step_sequence_id']
|
|
559
|
+
if resp is None:
|
|
560
|
+
resp, is_channel_notify = 0, True
|
|
561
|
+
if not is_channel_notify and jobstate.workflow_commands:
|
|
562
|
+
stdout.extend(jobstate.workflow_commands)
|
|
563
|
+
jobstate.workflow_commands.clear()
|
|
564
|
+
|
|
543
565
|
has_artifacts = False
|
|
544
566
|
for line in stdout:
|
|
545
567
|
# Parsing stdout for workflow commands
|
|
@@ -548,6 +570,10 @@ def process_output(
|
|
|
548
570
|
jobstate.stop_command = None
|
|
549
571
|
continue
|
|
550
572
|
|
|
573
|
+
if is_channel_notify and any(p.match(line) for p in COMMAND_PATTERNS):
|
|
574
|
+
jobstate.workflow_commands.append(line)
|
|
575
|
+
continue
|
|
576
|
+
|
|
551
577
|
if wcmd := ATTACH_COMMAND.match(line):
|
|
552
578
|
resp = _attach(wcmd.group(2), wcmd.group(1))
|
|
553
579
|
elif wcmd := UPLOAD_COMMAND.match(line):
|
|
@@ -569,11 +595,20 @@ def process_output(
|
|
|
569
595
|
for line in stderr:
|
|
570
596
|
logs.append(mask(line, jobstate).rstrip())
|
|
571
597
|
|
|
598
|
+
if is_channel_notify:
|
|
599
|
+
notify = make_event(EXECUTIONRESULT, metadata=deepcopy(metadata), status=resp)
|
|
600
|
+
notify['metadata']['step_sequence_id_origin'] = metadata['step_sequence_id']
|
|
601
|
+
notify['metadata']['step_sequence_id'] = CHANNEL_NOTIFY
|
|
602
|
+
notify['logs'] = logs
|
|
603
|
+
if notify['metadata'].get('artifacts'):
|
|
604
|
+
del notify['metadata']['artifacts']
|
|
605
|
+
return notify
|
|
606
|
+
|
|
572
607
|
if metadata.get('artifacts'):
|
|
573
608
|
del metadata['artifacts']
|
|
574
609
|
|
|
575
610
|
opentf_variables = None
|
|
576
|
-
if
|
|
611
|
+
if step_sequence_id != CHANNEL_RELEASE:
|
|
577
612
|
if variables:
|
|
578
613
|
opentf_variables = _read_opentf_variables(variables)
|
|
579
614
|
else:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opentf-toolkit-nightly
|
|
3
|
-
Version: 0.63.0.
|
|
3
|
+
Version: 0.63.0.dev1406
|
|
4
4
|
Summary: OpenTestFactory Orchestrator Toolkit
|
|
5
5
|
Home-page: https://gitlab.com/henixdevelopment/open-source/opentestfactory/python-toolkit
|
|
6
6
|
Author: Martin Lafaix
|
|
@@ -56,13 +56,13 @@ opentf/schemas/opentestfactory.org/v1beta1/ServiceConfig.json,sha256=m5ZgWAKbutu
|
|
|
56
56
|
opentf/schemas/opentestfactory.org/v1beta1/Workflow.json,sha256=QZ8mM9PhzsI9gTmwmKTWYNoRn--rtcM3L0PzgnPBfMU,15424
|
|
57
57
|
opentf/schemas/opentestfactory.org/v1beta2/ServiceConfig.json,sha256=rEvK2YWL5lG94_qYgR_GnLWNsaQhaQ-2kuZdWJr5NnY,3517
|
|
58
58
|
opentf/scripts/launch_java_service.sh,sha256=S0jAaCuv2sZy0Gf2NGBuPX-eD531rcM-b0fNyhmzSjw,2423
|
|
59
|
-
opentf/scripts/startup.py,sha256=
|
|
59
|
+
opentf/scripts/startup.py,sha256=DLanDaXutUTYcG2PwoJ34QH-5G0TwfLUY_xy1VkVOqA,23202
|
|
60
60
|
opentf/toolkit/__init__.py,sha256=YnH66dmePAIU7dq_xWFYTIEUrsL9qV9f82LRDiBzbzs,22057
|
|
61
|
-
opentf/toolkit/channels.py,sha256=
|
|
61
|
+
opentf/toolkit/channels.py,sha256=8WuybkK7HZpTvCqstnik6cz-OGd7p4AMBAfBJX3E3zA,27389
|
|
62
62
|
opentf/toolkit/core.py,sha256=jMBDIYZ8Qn3BvsysfKoG0iTtjOnZsggetpH3eXygCsI,9636
|
|
63
63
|
opentf/toolkit/models.py,sha256=PNfXVQbeyOwDfaNrLjcfhYm6duMSlNWBtZsWZcs53ag,6583
|
|
64
|
-
opentf_toolkit_nightly-0.63.0.
|
|
65
|
-
opentf_toolkit_nightly-0.63.0.
|
|
66
|
-
opentf_toolkit_nightly-0.63.0.
|
|
67
|
-
opentf_toolkit_nightly-0.63.0.
|
|
68
|
-
opentf_toolkit_nightly-0.63.0.
|
|
64
|
+
opentf_toolkit_nightly-0.63.0.dev1406.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
65
|
+
opentf_toolkit_nightly-0.63.0.dev1406.dist-info/METADATA,sha256=EXkrO2T8qRPNdSP83yiGluJDu-aq7zwXDY4mDbsrbUg,2215
|
|
66
|
+
opentf_toolkit_nightly-0.63.0.dev1406.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
67
|
+
opentf_toolkit_nightly-0.63.0.dev1406.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
|
|
68
|
+
opentf_toolkit_nightly-0.63.0.dev1406.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|