torizon-templates-utils 0.0.11__py3-none-any.whl → 1.1.0__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.
- torizon_templates_utils/tasks.py +56 -6
- {torizon_templates_utils-0.0.11.dist-info → torizon_templates_utils-1.1.0.dist-info}/METADATA +1 -1
- {torizon_templates_utils-0.0.11.dist-info → torizon_templates_utils-1.1.0.dist-info}/RECORD +5 -5
- {torizon_templates_utils-0.0.11.dist-info → torizon_templates_utils-1.1.0.dist-info}/WHEEL +1 -1
- {torizon_templates_utils-0.0.11.dist-info → torizon_templates_utils-1.1.0.dist-info}/top_level.txt +0 -0
torizon_templates_utils/tasks.py
CHANGED
|
@@ -13,6 +13,12 @@ from torizon_templates_utils.colors import print, Color
|
|
|
13
13
|
|
|
14
14
|
T = TypeVar('T')
|
|
15
15
|
|
|
16
|
+
REPLACE_WHITELIST = [
|
|
17
|
+
"torizon_",
|
|
18
|
+
"docker_",
|
|
19
|
+
"inputBox-"
|
|
20
|
+
]
|
|
21
|
+
|
|
16
22
|
def replace_tasks_input():
|
|
17
23
|
for file in Path('.').rglob('*.json'):
|
|
18
24
|
print(file, flush=True)
|
|
@@ -23,9 +29,9 @@ def replace_tasks_input():
|
|
|
23
29
|
with open(file, 'r') as f:
|
|
24
30
|
content = f.read()
|
|
25
31
|
|
|
26
|
-
content = content.replace("input:dockerLogin", "command:docker_login")
|
|
27
|
-
content = content.replace("input:dockerImageRegistry", "command:docker_registry")
|
|
28
|
-
content = content.replace("input:dockerPsswd", "command:docker_password")
|
|
32
|
+
content = content.replace("input:dockerLogin", "command:docker_login.__change__")
|
|
33
|
+
content = content.replace("input:dockerImageRegistry", "command:inputBox-docker_registry.__change__")
|
|
34
|
+
content = content.replace("input:dockerPsswd", "command:docker_password.__change__")
|
|
29
35
|
|
|
30
36
|
with open(file, 'w') as f:
|
|
31
37
|
f.write(content)
|
|
@@ -476,8 +482,8 @@ class TaskRunner:
|
|
|
476
482
|
self.__can_receive_interactive_input = True
|
|
477
483
|
|
|
478
484
|
# environment configs
|
|
479
|
-
if "
|
|
480
|
-
os.environ["config:docker_password"] = os.environ["
|
|
485
|
+
if "DOCKER_PASSWORD" in os.environ:
|
|
486
|
+
os.environ["config:docker_password"] = os.environ["DOCKER_PASSWORD"]
|
|
481
487
|
|
|
482
488
|
if "GITLAB_CI" in os.environ:
|
|
483
489
|
self.__gitlab_ci = True
|
|
@@ -570,7 +576,42 @@ class TaskRunner:
|
|
|
570
576
|
|
|
571
577
|
for value in env:
|
|
572
578
|
if "${command:torizon_" in value:
|
|
579
|
+
# here is not needed to clean the torizon_<prop>.<project_name>
|
|
580
|
+
# because this will be handled on the cmd args check
|
|
573
581
|
value = value.replace("${command:torizon_", "${config:torizon_")
|
|
582
|
+
|
|
583
|
+
ret.append(value)
|
|
584
|
+
|
|
585
|
+
return ret
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
def __check_input_boxes(self, env: List[str]) -> List[str]:
|
|
589
|
+
ret: List[str] = []
|
|
590
|
+
|
|
591
|
+
for value in env:
|
|
592
|
+
value = value.replace("${command:inputBox-", "${config:")
|
|
593
|
+
ret.append(value)
|
|
594
|
+
|
|
595
|
+
return ret
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
def __check_cmd_args(self, env: List[str]) -> List[str]:
|
|
599
|
+
ret: List[str] = []
|
|
600
|
+
|
|
601
|
+
for value in env:
|
|
602
|
+
for whitelisted_start in REPLACE_WHITELIST:
|
|
603
|
+
if value.startswith("${command:" + whitelisted_start) or value.startswith("${config:" + whitelisted_start):
|
|
604
|
+
|
|
605
|
+
if "." in value:
|
|
606
|
+
value_p1, value_p2 = value.split(".", 1)
|
|
607
|
+
ret_p2 = value_p2.split("}", 1)
|
|
608
|
+
|
|
609
|
+
if len(ret_p2) > 1:
|
|
610
|
+
value = f"{value_p1}}}{ret_p2[1]}"
|
|
611
|
+
else:
|
|
612
|
+
value = f"{value_p1}}}"
|
|
613
|
+
break
|
|
614
|
+
|
|
574
615
|
ret.append(value)
|
|
575
616
|
|
|
576
617
|
return ret
|
|
@@ -827,7 +868,9 @@ class TaskRunner:
|
|
|
827
868
|
|
|
828
869
|
if _env_value:
|
|
829
870
|
expvalue = [_env_value]
|
|
871
|
+
expvalue = self.__check_cmd_args(expvalue)
|
|
830
872
|
expvalue = self.__check_workspace_folder(expvalue)
|
|
873
|
+
expvalue = self.__check_input_boxes(expvalue)
|
|
831
874
|
expvalue = self.__check_torizon_inputs(expvalue)
|
|
832
875
|
expvalue = self.__check_docker_inputs(expvalue)
|
|
833
876
|
expvalue = self.__check_tcb_inputs(expvalue)
|
|
@@ -888,7 +931,9 @@ class TaskRunner:
|
|
|
888
931
|
_cmd = _task.command
|
|
889
932
|
|
|
890
933
|
# the cmd itself can use the mechanism to replace stuff
|
|
934
|
+
_cmd = self.__check_cmd_args([_cmd])[0]
|
|
891
935
|
_cmd = self.__check_workspace_folder([_cmd])[0]
|
|
936
|
+
_cmd = self.__check_input_boxes([_cmd])[0]
|
|
892
937
|
_cmd = self.__check_torizon_inputs([_cmd])[0]
|
|
893
938
|
_cmd = self.__check_docker_inputs([_cmd])[0]
|
|
894
939
|
_cmd = self.__check_tcb_inputs([_cmd])[0]
|
|
@@ -916,7 +961,9 @@ class TaskRunner:
|
|
|
916
961
|
# FIXME: The scape args was in the powershell implementation
|
|
917
962
|
# but when used on Python it generates weird behavior
|
|
918
963
|
# _args = self.__scape_args(_args)
|
|
964
|
+
_args = self.__check_cmd_args(_args)
|
|
919
965
|
_args = self.__check_workspace_folder(_args)
|
|
966
|
+
_args = self.__check_input_boxes(_args)
|
|
920
967
|
_args = self.__check_torizon_inputs(_args)
|
|
921
968
|
_args = self.__check_docker_inputs(_args)
|
|
922
969
|
_args = self.__check_tcb_inputs(_args)
|
|
@@ -924,9 +971,12 @@ class TaskRunner:
|
|
|
924
971
|
_args = self.__check_vscode_env(_args)
|
|
925
972
|
_args = self.__check_config(_args)
|
|
926
973
|
_args = self.__check_workspace_folder(_args)
|
|
974
|
+
|
|
975
|
+
if _shell:
|
|
976
|
+
_args = self.__check_long_args(_args)
|
|
977
|
+
|
|
927
978
|
# FIXME: These was in the powershell implementation
|
|
928
979
|
# but when used on Python it generates weird behavior
|
|
929
|
-
# _args = self.__check_long_args(_args)
|
|
930
980
|
# _args = self.__quoting_special_chars(_args)
|
|
931
981
|
|
|
932
982
|
# if in gitlab ci env we need to replace the DOCKER_HOST
|
{torizon_templates_utils-0.0.11.dist-info → torizon_templates_utils-1.1.0.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: torizon_templates_utils
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Package with utilities for Torizon Templates scripts
|
|
5
5
|
Author-email: Matheus Castello <matheus.castello@toradex.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/torizon/vscode-torizon-templates
|
|
@@ -5,8 +5,8 @@ torizon_templates_utils/colors.py,sha256=Y1FZ0HtKvXfLGYTDclsXubtZCQ-epuch5Dgk1DJ
|
|
|
5
5
|
torizon_templates_utils/debug.py,sha256=OfdKSdN1kypuJnV_WcPa9bvonjyDvXvA3QTmc1iKyjw,556
|
|
6
6
|
torizon_templates_utils/errors.py,sha256=Wkk0AeCx0KQW-Qlu_5A6GYaGUkaJU79Mok8lZuZKHjM,1425
|
|
7
7
|
torizon_templates_utils/network.py,sha256=SFZivQumv-pVL0vglYCW3JS6WWCUG8asoMdgljeJZ24,1703
|
|
8
|
-
torizon_templates_utils/tasks.py,sha256=
|
|
9
|
-
torizon_templates_utils-
|
|
10
|
-
torizon_templates_utils-
|
|
11
|
-
torizon_templates_utils-
|
|
12
|
-
torizon_templates_utils-
|
|
8
|
+
torizon_templates_utils/tasks.py,sha256=nUaivwvFnmpRvqr7rV2Vmrckui_sSoIYpzxSvKOw4rs,36168
|
|
9
|
+
torizon_templates_utils-1.1.0.dist-info/METADATA,sha256=_3L-q3N1QO6pQt2M8-iM1-DUy4x9RvvuBaMLYVjigtQ,976
|
|
10
|
+
torizon_templates_utils-1.1.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
11
|
+
torizon_templates_utils-1.1.0.dist-info/top_level.txt,sha256=qlOkS1ASF5C-kSfpbiWbVHJFgmQ0RN6iunmLArNt6zc,24
|
|
12
|
+
torizon_templates_utils-1.1.0.dist-info/RECORD,,
|
{torizon_templates_utils-0.0.11.dist-info → torizon_templates_utils-1.1.0.dist-info}/top_level.txt
RENAMED
|
File without changes
|