zrb 0.0.86__py3-none-any.whl → 0.0.87__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.
- zrb/__init__.py +3 -1
- zrb/action/runner.py +7 -3
- zrb/builtin/__init__.py +1 -1
- zrb/builtin/base64.py +1 -1
- zrb/builtin/devtool/devtool_install.py +3 -1
- zrb/builtin/env.py +6 -3
- zrb/builtin/explain.py +3 -1
- zrb/builtin/generator/__init__.py +4 -8
- zrb/builtin/generator/app_generator/add.py +6 -6
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/add.py +60 -50
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/container.py +1 -1
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/deployment.py +2 -2
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/image.py +1 -1
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +4 -2
- zrb/builtin/generator/cmd_task/add.py +6 -6
- zrb/builtin/generator/cmd_task/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/generator/{_common → common}/helper.py +6 -0
- zrb/builtin/generator/{_common → common}/task_factory.py +9 -5
- zrb/builtin/generator/docker_compose_task/add.py +8 -8
- zrb/builtin/generator/docker_compose_task/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/generator/fastapp/add.py +24 -24
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_common.py +2 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/container.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/deployment.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/frontend.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/image.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/load_test.py +3 -2
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/local.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/test.py +2 -4
- zrb/builtin/generator/fastapp_crud/add.py +8 -121
- zrb/builtin/generator/fastapp_crud/helper.py +115 -0
- zrb/builtin/generator/fastapp_crud/{add_navigation.py → task_factory.py} +5 -3
- zrb/builtin/generator/fastapp_field/add.py +8 -280
- zrb/builtin/generator/fastapp_field/helper.py +283 -0
- zrb/builtin/generator/fastapp_module/add.py +19 -328
- zrb/builtin/generator/fastapp_module/helper.py +326 -0
- zrb/builtin/generator/pip_package/add.py +8 -8
- zrb/builtin/generator/pip_package/template/_automate/snake_zrb_package_name/local.py +1 -1
- zrb/builtin/generator/project/create.py +5 -3
- zrb/builtin/generator/project_task/task_factory.py +33 -21
- zrb/builtin/generator/project_task/template/_automate/_project/build_project_images.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/deploy_project.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/destroy_project.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/push_project_images.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/remove_project_containers.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/start_project.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/start_project_containers.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/stop_project_containers.py +1 -1
- zrb/builtin/generator/python_task/add.py +6 -6
- zrb/builtin/generator/python_task/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/generator/simple_python_app/add.py +28 -30
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/container.py +1 -1
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/deployment.py +1 -1
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/image.py +1 -1
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/local.py +1 -1
- zrb/builtin/git.py +1 -1
- zrb/builtin/md5.py +1 -1
- zrb/builtin/project.py +1 -1
- zrb/builtin/ubuntu.py +1 -1
- zrb/config/config.py +8 -6
- zrb/helper/accessories/color.py +5 -1
- zrb/helper/accessories/icon.py +2 -0
- zrb/helper/accessories/name.py +2 -0
- zrb/helper/advertisement.py +1 -0
- zrb/helper/cli.py +5 -1
- zrb/helper/codemod/add_argument_to_function.py +3 -0
- zrb/helper/codemod/add_argument_to_function_call.py +3 -0
- zrb/helper/codemod/add_assert_resource.py +2 -0
- zrb/helper/codemod/add_function_call.py +2 -0
- zrb/helper/codemod/add_import_module.py +3 -0
- zrb/helper/codemod/add_key_value_to_dict.py +2 -0
- zrb/helper/codemod/add_property_to_class.py +3 -0
- zrb/helper/codemod/add_upstream_to_task.py +3 -0
- zrb/helper/codemod/append_code_to_function.py +3 -0
- zrb/helper/codemod/format_code.py +2 -0
- zrb/helper/default_env.py +2 -0
- zrb/helper/docker_compose/fetch_external_env.py +3 -0
- zrb/helper/docker_compose/file.py +4 -0
- zrb/helper/env_map/fetch.py +7 -0
- zrb/helper/file/text.py +4 -0
- zrb/helper/git/detect_changes.py +4 -0
- zrb/helper/loader/load_module.py +2 -0
- zrb/helper/map/conversion.py +2 -0
- zrb/helper/string/conversion.py +5 -0
- zrb/helper/string/double_quote.py +6 -2
- zrb/helper/string/jinja.py +2 -0
- zrb/helper/string/parse_replacement.py +2 -0
- zrb/helper/util.py +13 -0
- zrb/task/any_task.py +2 -2
- zrb/task/base_task.py +15 -15
- zrb/task/base_task_composite.py +3 -3
- zrb/task/cmd_task.py +2 -2
- zrb/task/decorator.py +2 -2
- zrb/task/docker_compose_task.py +2 -2
- zrb/task/flow_task.py +5 -5
- zrb/task/http_checker.py +2 -2
- zrb/task/path_checker.py +2 -2
- zrb/task/port_checker.py +2 -2
- zrb/task/resource_maker.py +3 -5
- zrb/task_input/any_input.py +23 -0
- zrb/task_input/base_input.py +46 -43
- zrb/task_input/float_input.py +0 -1
- {zrb-0.0.86.dist-info → zrb-0.0.87.dist-info}/METADATA +1 -1
- {zrb-0.0.86.dist-info → zrb-0.0.87.dist-info}/RECORD +111 -108
- zrb/config.toml +0 -0
- /zrb/builtin/generator/{_common → common}/__init__.py +0 -0
- /zrb/builtin/generator/{_common → common}/task_input.py +0 -0
- /zrb/builtin/{_group.py → group.py} +0 -0
- /zrb/task_input/{_constant.py → constant.py} +0 -0
- {zrb-0.0.86.dist-info → zrb-0.0.87.dist-info}/LICENSE +0 -0
- {zrb-0.0.86.dist-info → zrb-0.0.87.dist-info}/WHEEL +0 -0
- {zrb-0.0.86.dist-info → zrb-0.0.87.dist-info}/entry_points.txt +0 -0
zrb/__init__.py
CHANGED
@@ -9,6 +9,7 @@ from .task.port_checker import PortChecker
|
|
9
9
|
from .task.path_checker import PathChecker
|
10
10
|
from .task.resource_maker import ResourceMaker, Replacement, ReplacementMutator
|
11
11
|
from .task.flow_task import FlowTask, FlowNode
|
12
|
+
from .task_input.any_input import AnyInput
|
12
13
|
from .task_input.task_input import Input
|
13
14
|
from .task_input.bool_input import BoolInput
|
14
15
|
from .task_input.choice_input import ChoiceInput
|
@@ -19,7 +20,7 @@ from .task_input.str_input import StrInput
|
|
19
20
|
from .task_env.env import Env
|
20
21
|
from .task_env.env_file import EnvFile
|
21
22
|
from .task_group.group import Group
|
22
|
-
from .builtin import
|
23
|
+
from .builtin import group as builtin_group
|
23
24
|
from .helper.default_env import inject_default_env
|
24
25
|
|
25
26
|
|
@@ -38,6 +39,7 @@ assert FlowTask
|
|
38
39
|
assert FlowNode
|
39
40
|
assert Replacement
|
40
41
|
assert ReplacementMutator
|
42
|
+
assert AnyInput
|
41
43
|
assert Input
|
42
44
|
assert BoolInput
|
43
45
|
assert ChoiceInput
|
zrb/action/runner.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
from typing import Any, Callable, Iterable, List, Mapping, Union
|
2
|
+
from typeguard import typechecked
|
2
3
|
from ..task_group.group import Group as TaskGroup
|
3
4
|
from ..task.any_task import AnyTask
|
4
5
|
import click
|
@@ -7,6 +8,7 @@ import sys
|
|
7
8
|
CliSubcommand = Union[click.Group, click.Command]
|
8
9
|
|
9
10
|
|
11
|
+
@typechecked
|
10
12
|
class Runner():
|
11
13
|
'''
|
12
14
|
Runner class.
|
@@ -32,7 +34,9 @@ class Runner():
|
|
32
34
|
cli.add_command(subcommand)
|
33
35
|
return cli
|
34
36
|
|
35
|
-
def _create_cli_subcommand(
|
37
|
+
def _create_cli_subcommand(
|
38
|
+
self, task: AnyTask
|
39
|
+
) -> Union[click.Group, click.Command]:
|
36
40
|
subcommand: CliSubcommand = self._create_cli_command(task)
|
37
41
|
task_group = task._group
|
38
42
|
while task_group is not None:
|
@@ -82,9 +86,9 @@ class Runner():
|
|
82
86
|
# if there are inputs with the same name, choose the first.
|
83
87
|
registered_input: Mapping[str, bool] = {}
|
84
88
|
for task_input in task_inputs:
|
85
|
-
if task_input.
|
89
|
+
if task_input.get_name() in registered_input:
|
86
90
|
continue
|
87
|
-
registered_input[task_input.
|
91
|
+
registered_input[task_input.get_name()] = True
|
88
92
|
param_decl = task_input.get_param_decl()
|
89
93
|
options = task_input.get_options()
|
90
94
|
command.params.append(click.Option(param_decl, **options))
|
zrb/builtin/__init__.py
CHANGED
zrb/builtin/base64.py
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
from typing import Any, Callable
|
2
|
+
from typeguard import typechecked
|
2
3
|
from ...config.config import get_current_shell
|
3
|
-
from .._group import dev_tool_install_group
|
4
4
|
from ...task.task import Task
|
5
5
|
from ...task.flow_task import FlowTask, FlowNode
|
6
6
|
from ...task_input.str_input import StrInput
|
7
7
|
from ...task_input.bool_input import BoolInput
|
8
8
|
from ...runner import runner
|
9
9
|
from ...helper.file.text import read_text_file_async, write_text_file_async
|
10
|
+
from ..group import dev_tool_install_group
|
10
11
|
import os
|
11
12
|
|
12
13
|
dir_path = os.path.dirname(__file__)
|
@@ -28,6 +29,7 @@ terminal_config_file_input = StrInput(
|
|
28
29
|
###############################################################################
|
29
30
|
|
30
31
|
|
32
|
+
@typechecked
|
31
33
|
def write_config(
|
32
34
|
template_file: str, config_file: str, remove_old_config: bool = False
|
33
35
|
) -> Callable[..., Any]:
|
zrb/builtin/env.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
from typing import Any,
|
2
|
-
from .
|
1
|
+
from typing import Any, List
|
2
|
+
from .group import env_group
|
3
3
|
from ..helper.accessories.color import colored
|
4
4
|
from ..task.decorator import python_task
|
5
5
|
from ..task.task import Task
|
@@ -22,9 +22,12 @@ async def get(*args: Any, **kwargs: Any):
|
|
22
22
|
names = list(env_map.keys())
|
23
23
|
names.sort()
|
24
24
|
colored_equal = colored('=', color='grey', attrs=['dark'])
|
25
|
+
env_lines: List[str] = []
|
25
26
|
for name in names:
|
26
27
|
value = env_map[name]
|
27
28
|
colored_name = colored(name, color='green', attrs=['bold'])
|
28
29
|
colored_value = colored(value, attrs=['bold'])
|
29
|
-
|
30
|
+
env_lines.append(f'{colored_name}{colored_equal}{colored_value}')
|
31
|
+
line_separator = '\n '
|
32
|
+
task.print_out(line_separator + line_separator.join(env_lines))
|
30
33
|
return env_map
|
zrb/builtin/explain.py
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
from typing import Any
|
2
|
-
from
|
2
|
+
from typeguard import typechecked
|
3
|
+
from .group import explain_group
|
3
4
|
from ..task.decorator import python_task
|
4
5
|
from ..task.task import Task
|
5
6
|
from ..runner import runner
|
6
7
|
|
7
8
|
|
9
|
+
@typechecked
|
8
10
|
def show_lines(task: Task, *lines: str):
|
9
11
|
separator = '\n '
|
10
12
|
task.print_out(
|
@@ -1,7 +1,5 @@
|
|
1
|
-
from .
|
2
|
-
from .
|
3
|
-
from ._common import task_factory
|
4
|
-
from .project_task import task_factory as project_task_factory
|
1
|
+
from . import common
|
2
|
+
from . import project_task
|
5
3
|
from .project.create import create_project
|
6
4
|
from .cmd_task.add import add_cmd_task
|
7
5
|
from .docker_compose_task.add import add_docker_compose_task
|
@@ -14,10 +12,8 @@ from .fastapp_field import add as add_fastapp_field
|
|
14
12
|
from .pip_package import add as add_pip_package
|
15
13
|
from .app_generator import add as add_app_generator
|
16
14
|
|
17
|
-
assert
|
18
|
-
assert
|
19
|
-
assert task_factory
|
20
|
-
assert project_task_factory
|
15
|
+
assert common
|
16
|
+
assert project_task
|
21
17
|
assert create_project
|
22
18
|
assert add_cmd_task
|
23
19
|
assert add_docker_compose_task
|
@@ -1,16 +1,16 @@
|
|
1
1
|
from typing import Any
|
2
|
-
from
|
2
|
+
from ..common.task_input import project_dir_input
|
3
|
+
from ..common.helper import (
|
4
|
+
validate_existing_project_dir, validate_inexisting_automation
|
5
|
+
)
|
6
|
+
from ..common.task_factory import create_register_module
|
7
|
+
from ...group import project_add_group
|
3
8
|
from ....task.decorator import python_task
|
4
9
|
from ....task.task import Task
|
5
10
|
from ....task.resource_maker import ResourceMaker
|
6
11
|
from ....task_input.str_input import StrInput
|
7
12
|
from ....helper.accessories.name import get_random_name
|
8
13
|
from ....runner import runner
|
9
|
-
from .._common.task_input import project_dir_input
|
10
|
-
from .._common.helper import (
|
11
|
-
validate_existing_project_dir, validate_inexisting_automation
|
12
|
-
)
|
13
|
-
from .._common.task_factory import create_register_module
|
14
14
|
|
15
15
|
import os
|
16
16
|
|
@@ -1,15 +1,27 @@
|
|
1
1
|
from typing import Any
|
2
|
-
from zrb.builtin import
|
2
|
+
from zrb.builtin.group import project_add_group
|
3
3
|
from zrb import Task, python_task, ResourceMaker, runner
|
4
|
-
from zrb.
|
5
|
-
|
6
|
-
|
4
|
+
from zrb.builtin.generator.common.task_input import (
|
5
|
+
project_dir_input, app_name_input, app_image_name_input, env_prefix_input,
|
6
|
+
http_port_input
|
7
|
+
)
|
8
|
+
from zrb.builtin.generator.common.helper import (
|
9
|
+
validate_existing_project_dir, validate_inexisting_automation
|
10
|
+
)
|
11
|
+
from zrb.builtin.generator.common.task_factory import create_register_module
|
12
|
+
from zrb.builtin.generator.project_task.task_factory import (
|
13
|
+
create_ensure_project_tasks, create_add_build_images_upstream,
|
14
|
+
create_add_deploy_upstream, create_add_destroy_upstream,
|
15
|
+
create_add_push_images_upstream, create_add_remove_containers_upstream,
|
16
|
+
create_add_start_containers_upstream, create_add_start_upstream,
|
17
|
+
create_add_stop_containers_upstream
|
7
18
|
)
|
8
19
|
|
9
20
|
import os
|
10
21
|
|
11
22
|
CURRENT_DIR = os.path.dirname(__file__)
|
12
23
|
SNAKE_APP_NAME_TPL = '{{util.to_snake_case(input.app_name)}}'
|
24
|
+
KEBAB_APP_NAME_TPL = '{{util.to_kebab_case(app_name)}}'
|
13
25
|
|
14
26
|
###############################################################################
|
15
27
|
# Task Definitions
|
@@ -19,18 +31,16 @@ SNAKE_APP_NAME_TPL = '{{util.to_snake_case(input.app_name)}}'
|
|
19
31
|
@python_task(
|
20
32
|
name='validate',
|
21
33
|
inputs=[
|
22
|
-
|
23
|
-
|
34
|
+
project_dir_input,
|
35
|
+
app_name_input
|
24
36
|
],
|
25
37
|
)
|
26
38
|
async def validate(*args: Any, **kwargs: Any):
|
27
39
|
project_dir = kwargs.get('project_dir')
|
28
|
-
|
40
|
+
validate_existing_project_dir(project_dir)
|
29
41
|
app_name = kwargs.get('app_name')
|
30
|
-
|
31
|
-
source_dir = os.path.join(
|
32
|
-
project_dir, 'src', f'{util.to_kebab_case(app_name)}'
|
33
|
-
)
|
42
|
+
validate_inexisting_automation(project_dir, app_name)
|
43
|
+
source_dir = os.path.join(project_dir, 'src', f'{KEBAB_APP_NAME_TPL}')
|
34
44
|
if os.path.exists(source_dir):
|
35
45
|
raise Exception(f'Source already exists: {source_dir}')
|
36
46
|
|
@@ -38,11 +48,11 @@ async def validate(*args: Any, **kwargs: Any):
|
|
38
48
|
copy_resource = ResourceMaker(
|
39
49
|
name='copy-resource',
|
40
50
|
inputs=[
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
51
|
+
project_dir_input,
|
52
|
+
app_name_input,
|
53
|
+
app_image_name_input,
|
54
|
+
http_port_input,
|
55
|
+
env_prefix_input,
|
46
56
|
],
|
47
57
|
upstreams=[validate],
|
48
58
|
replacements={
|
@@ -59,111 +69,111 @@ copy_resource = ResourceMaker(
|
|
59
69
|
]
|
60
70
|
)
|
61
71
|
|
62
|
-
register_local_module =
|
72
|
+
register_local_module = create_register_module(
|
63
73
|
module_path=f'_automate.{SNAKE_APP_NAME_TPL}.local',
|
64
74
|
alias=f'{SNAKE_APP_NAME_TPL}_local',
|
65
|
-
inputs=[
|
75
|
+
inputs=[app_name_input],
|
66
76
|
upstreams=[copy_resource]
|
67
77
|
)
|
68
78
|
|
69
|
-
register_container_module =
|
79
|
+
register_container_module = create_register_module(
|
70
80
|
module_path=f'_automate.{SNAKE_APP_NAME_TPL}.container',
|
71
81
|
alias=f'{SNAKE_APP_NAME_TPL}_container',
|
72
|
-
inputs=[
|
82
|
+
inputs=[app_name_input],
|
73
83
|
upstreams=[register_local_module]
|
74
84
|
)
|
75
85
|
|
76
|
-
register_image_module =
|
86
|
+
register_image_module = create_register_module(
|
77
87
|
module_path=f'_automate.{SNAKE_APP_NAME_TPL}.image',
|
78
88
|
alias=f'{SNAKE_APP_NAME_TPL}_image',
|
79
|
-
inputs=[
|
89
|
+
inputs=[app_name_input],
|
80
90
|
upstreams=[register_container_module]
|
81
91
|
)
|
82
92
|
|
83
|
-
register_deployment_module =
|
93
|
+
register_deployment_module = create_register_module(
|
84
94
|
module_path=f'_automate.{SNAKE_APP_NAME_TPL}.deployment',
|
85
95
|
alias=f'{SNAKE_APP_NAME_TPL}_deployment',
|
86
|
-
inputs=[
|
96
|
+
inputs=[app_name_input],
|
87
97
|
upstreams=[register_image_module]
|
88
98
|
)
|
89
99
|
|
90
|
-
ensure_project_tasks =
|
100
|
+
ensure_project_tasks = create_ensure_project_tasks(
|
91
101
|
upstreams=[copy_resource]
|
92
102
|
)
|
93
103
|
|
94
|
-
|
104
|
+
add_start_upstream = create_add_start_upstream(
|
95
105
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.local',
|
96
106
|
upstream_task_var=f'start_{SNAKE_APP_NAME_TPL}',
|
97
107
|
upstreams=[ensure_project_tasks],
|
98
|
-
inputs=[
|
108
|
+
inputs=[app_name_input]
|
99
109
|
)
|
100
110
|
|
101
|
-
|
111
|
+
add_start_container_upstream = create_add_start_containers_upstream(
|
102
112
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.container',
|
103
113
|
upstream_task_var=f'start_{SNAKE_APP_NAME_TPL}_container',
|
104
114
|
upstreams=[ensure_project_tasks],
|
105
|
-
inputs=[
|
115
|
+
inputs=[app_name_input]
|
106
116
|
)
|
107
117
|
|
108
|
-
|
118
|
+
add_stop_container_upstream = create_add_stop_containers_upstream(
|
109
119
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.container',
|
110
120
|
upstream_task_var=f'stop_{SNAKE_APP_NAME_TPL}_container',
|
111
121
|
upstreams=[ensure_project_tasks],
|
112
|
-
inputs=[
|
122
|
+
inputs=[app_name_input]
|
113
123
|
)
|
114
124
|
|
115
|
-
|
125
|
+
add_remove_container_upstream = create_add_remove_containers_upstream(
|
116
126
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.container',
|
117
127
|
upstream_task_var=f'remove_{SNAKE_APP_NAME_TPL}_container',
|
118
128
|
upstreams=[ensure_project_tasks],
|
119
|
-
inputs=[
|
129
|
+
inputs=[app_name_input]
|
120
130
|
)
|
121
131
|
|
122
|
-
|
132
|
+
add_build_image_upstream = create_add_build_images_upstream(
|
123
133
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.image',
|
124
134
|
upstream_task_var=f'build_{SNAKE_APP_NAME_TPL}_image',
|
125
135
|
upstreams=[ensure_project_tasks],
|
126
|
-
inputs=[
|
136
|
+
inputs=[app_name_input]
|
127
137
|
)
|
128
138
|
|
129
|
-
|
139
|
+
add_push_image_upstream = create_add_push_images_upstream(
|
130
140
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.image',
|
131
141
|
upstream_task_var=f'push_{SNAKE_APP_NAME_TPL}_image',
|
132
142
|
upstreams=[ensure_project_tasks],
|
133
|
-
inputs=[
|
143
|
+
inputs=[app_name_input]
|
134
144
|
)
|
135
145
|
|
136
|
-
|
146
|
+
add_deploy_upstream = create_add_deploy_upstream(
|
137
147
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.deployment',
|
138
148
|
upstream_task_var=f'deploy_{SNAKE_APP_NAME_TPL}',
|
139
149
|
upstreams=[ensure_project_tasks],
|
140
|
-
inputs=[
|
150
|
+
inputs=[app_name_input]
|
141
151
|
)
|
142
152
|
|
143
|
-
|
153
|
+
add_destroy_upstream = create_add_destroy_upstream(
|
144
154
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.deployment',
|
145
155
|
upstream_task_var=f'destroy_{SNAKE_APP_NAME_TPL}',
|
146
156
|
upstreams=[ensure_project_tasks],
|
147
|
-
inputs=[
|
157
|
+
inputs=[app_name_input]
|
148
158
|
)
|
149
159
|
|
150
160
|
|
151
161
|
@python_task(
|
152
162
|
name='simple-python-app',
|
153
|
-
group=
|
163
|
+
group=project_add_group,
|
154
164
|
upstreams=[
|
155
165
|
register_local_module,
|
156
166
|
register_container_module,
|
157
167
|
register_image_module,
|
158
168
|
register_deployment_module,
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
169
|
+
add_start_upstream,
|
170
|
+
add_start_container_upstream,
|
171
|
+
add_stop_container_upstream,
|
172
|
+
add_remove_container_upstream,
|
173
|
+
add_build_image_upstream,
|
174
|
+
add_push_image_upstream,
|
175
|
+
add_deploy_upstream,
|
176
|
+
add_destroy_upstream
|
167
177
|
],
|
168
178
|
runner=runner
|
169
179
|
)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from zrb import (
|
2
2
|
DockerComposeTask, Env, EnvFile, HTTPChecker, ServiceConfig, runner
|
3
3
|
)
|
4
|
-
from zrb.builtin.
|
4
|
+
from zrb.builtin.group import project_group
|
5
5
|
from ._common import (
|
6
6
|
RESOURCE_DIR, APP_DIR, local_input, host_input, https_input
|
7
7
|
)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
from zrb import CmdTask, Env, EnvFile, IntInput, StrInput,
|
2
|
-
from zrb.builtin.
|
1
|
+
from zrb import CmdTask, Env, EnvFile, IntInput, StrInput, runner
|
2
|
+
from zrb.builtin.group import project_group
|
3
3
|
from .image import push_snake_zrb_app_name_image, image_input, image_env
|
4
4
|
from ._common import (
|
5
5
|
CURRENT_DIR, DEPLOYMENT_DIR, TEMPLATE_ENV_FILE_NAME
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from zrb import CmdTask, Env, EnvFile, HTTPChecker, runner
|
2
|
-
from zrb.builtin.
|
2
|
+
from zrb.builtin.group import project_group
|
3
3
|
from ._common import (
|
4
4
|
CURRENT_DIR, APP_DIR, TEMPLATE_ENV_FILE_NAME,
|
5
5
|
local_input, host_input, https_input
|
@@ -10,7 +10,9 @@ import os
|
|
10
10
|
# Env File Definitions
|
11
11
|
###############################################################################
|
12
12
|
|
13
|
-
app_env_file = EnvFile(
|
13
|
+
app_env_file = EnvFile(
|
14
|
+
env_file=TEMPLATE_ENV_FILE_NAME, prefix='ZRB_ENV_PREFIX'
|
15
|
+
)
|
14
16
|
|
15
17
|
###############################################################################
|
16
18
|
# Task Definitions
|
@@ -1,14 +1,14 @@
|
|
1
1
|
from typing import Any
|
2
|
-
from
|
2
|
+
from ..common.task_input import project_dir_input, task_name_input
|
3
|
+
from ..common.helper import (
|
4
|
+
validate_existing_project_dir, validate_inexisting_automation
|
5
|
+
)
|
6
|
+
from ..common.task_factory import create_register_module
|
7
|
+
from ...group import project_add_group
|
3
8
|
from ....task.task import Task
|
4
9
|
from ....task.decorator import python_task
|
5
10
|
from ....task.resource_maker import ResourceMaker
|
6
11
|
from ....runner import runner
|
7
|
-
from .._common.task_input import project_dir_input, task_name_input
|
8
|
-
from .._common.helper import (
|
9
|
-
validate_existing_project_dir, validate_inexisting_automation
|
10
|
-
)
|
11
|
-
from .._common.task_factory import create_register_module
|
12
12
|
|
13
13
|
import os
|
14
14
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
from typing import Optional
|
2
|
+
from typeguard import typechecked
|
2
3
|
from ....helper.codemod.add_assert_resource import add_assert_resource
|
3
4
|
from ....helper.codemod.add_import_module import add_import_module
|
4
5
|
from ....helper.file.text import read_text_file_async, write_text_file_async
|
@@ -6,16 +7,19 @@ from ....helper import util
|
|
6
7
|
import os
|
7
8
|
|
8
9
|
|
10
|
+
@typechecked
|
9
11
|
def validate_existing_project_dir(project_dir: str):
|
10
12
|
if not os.path.isfile(os.path.join(project_dir, 'zrb_init.py')):
|
11
13
|
raise Exception(f'Not a project: {project_dir}')
|
12
14
|
|
13
15
|
|
16
|
+
@typechecked
|
14
17
|
def validate_inexisting_automation(project_dir: str, automation_name: str):
|
15
18
|
validate_inexisting_automation_package(project_dir, automation_name)
|
16
19
|
validate_inexisting_automation_module(project_dir, automation_name)
|
17
20
|
|
18
21
|
|
22
|
+
@typechecked
|
19
23
|
def validate_inexisting_automation_package(
|
20
24
|
project_dir: str, package_name: str
|
21
25
|
):
|
@@ -26,6 +30,7 @@ def validate_inexisting_automation_package(
|
|
26
30
|
raise Exception(f'Automation package already exists: {package_dir}')
|
27
31
|
|
28
32
|
|
33
|
+
@typechecked
|
29
34
|
def validate_inexisting_automation_module(project_dir: str, module_name: str):
|
30
35
|
module_file = os.path.join(
|
31
36
|
project_dir, '_automate', f'{util.to_snake_case(module_name)}.py'
|
@@ -34,6 +39,7 @@ def validate_inexisting_automation_module(project_dir: str, module_name: str):
|
|
34
39
|
raise Exception(f'Automation module already exists: {module_file}')
|
35
40
|
|
36
41
|
|
42
|
+
@typechecked
|
37
43
|
async def register_module_to_project(
|
38
44
|
project_dir: str, module_path: str, alias: Optional[str] = None
|
39
45
|
):
|
@@ -1,19 +1,22 @@
|
|
1
1
|
from typing import Any, List, Optional
|
2
|
+
from typeguard import typechecked
|
2
3
|
from .task_input import project_dir_input
|
3
4
|
from .helper import validate_existing_project_dir, register_module_to_project
|
4
5
|
from ....task.decorator import python_task
|
6
|
+
from ....task.any_task import AnyTask
|
5
7
|
from ....task.task import Task
|
6
|
-
from ....task_input.
|
8
|
+
from ....task_input.any_input import AnyInput
|
7
9
|
from ....helper.file.text import read_text_file_async, write_text_file_async
|
8
10
|
from ....helper.codemod.add_import_module import add_import_module
|
9
11
|
from ....helper.codemod.add_upstream_to_task import add_upstream_to_task
|
10
12
|
import os
|
11
13
|
|
12
14
|
|
15
|
+
@typechecked
|
13
16
|
def create_register_module(
|
14
17
|
module_path: str,
|
15
|
-
inputs: Optional[List[
|
16
|
-
upstreams: Optional[List[
|
18
|
+
inputs: Optional[List[AnyInput]] = None,
|
19
|
+
upstreams: Optional[List[AnyTask]] = None,
|
17
20
|
alias: Optional[str] = None
|
18
21
|
) -> Task:
|
19
22
|
@python_task(
|
@@ -41,13 +44,14 @@ def create_register_module(
|
|
41
44
|
return register_module
|
42
45
|
|
43
46
|
|
47
|
+
@typechecked
|
44
48
|
def create_add_upstream(
|
45
49
|
task_file_name: str,
|
46
50
|
task_name: str,
|
47
51
|
upstream_module: str,
|
48
52
|
upstream_task_var: str,
|
49
|
-
inputs: Optional[List[
|
50
|
-
upstreams: Optional[List[
|
53
|
+
inputs: Optional[List[AnyInput]] = None,
|
54
|
+
upstreams: Optional[List[AnyTask]] = None
|
51
55
|
) -> Task:
|
52
56
|
@python_task(
|
53
57
|
name='register-upstream',
|
@@ -1,17 +1,17 @@
|
|
1
1
|
from typing import Any
|
2
|
-
from
|
2
|
+
from ..common.task_input import (
|
3
|
+
project_dir_input, task_name_input, http_port_input, env_prefix_input
|
4
|
+
)
|
5
|
+
from ..common.helper import (
|
6
|
+
validate_existing_project_dir, validate_inexisting_automation
|
7
|
+
)
|
8
|
+
from ..common.task_factory import create_register_module
|
9
|
+
from ...group import project_add_group
|
3
10
|
from ....task.task import Task
|
4
11
|
from ....task.decorator import python_task
|
5
12
|
from ....task_input.str_input import StrInput
|
6
13
|
from ....task.resource_maker import ResourceMaker
|
7
14
|
from ....runner import runner
|
8
|
-
from .._common.task_input import (
|
9
|
-
project_dir_input, task_name_input, http_port_input, env_prefix_input
|
10
|
-
)
|
11
|
-
from .._common.helper import (
|
12
|
-
validate_existing_project_dir, validate_inexisting_automation
|
13
|
-
)
|
14
|
-
from .._common.task_factory import create_register_module
|
15
15
|
from ....helper import util
|
16
16
|
|
17
17
|
import os
|