ominfra 0.0.0.dev189__tar.gz → 0.0.0.dev191__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {ominfra-0.0.0.dev189/ominfra.egg-info → ominfra-0.0.0.dev191}/PKG-INFO +4 -3
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/__about__.py +1 -0
- ominfra-0.0.0.dev191/ominfra/manage/deploy/apps.py +198 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/commands.py +1 -1
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/conf/manager.py +82 -17
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/conf/specs.py +9 -0
- ominfra-0.0.0.dev191/ominfra/manage/deploy/deploy.py +327 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/inject.py +4 -6
- ominfra-0.0.0.dev191/ominfra/manage/deploy/nginx.py +8 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/paths/paths.py +5 -1
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/specs.py +21 -1
- ominfra-0.0.0.dev191/ominfra/manage/deploy/systemd.py +131 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/tags.py +1 -1
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/venvs.py +8 -6
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/scripts/manage.py +733 -160
- ominfra-0.0.0.dev191/ominfra/systemd.py +49 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191/ominfra.egg-info}/PKG-INFO +4 -3
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra.egg-info/SOURCES.txt +3 -1
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra.egg-info/requires.txt +3 -2
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/pyproject.toml +4 -3
- ominfra-0.0.0.dev189/ominfra/manage/deploy/apps.py +0 -177
- ominfra-0.0.0.dev189/ominfra/manage/deploy/deploy.py +0 -34
- ominfra-0.0.0.dev189/ominfra/manage/deploy/driver.py +0 -62
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/LICENSE +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/MANIFEST.in +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/README.rst +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/.manifests.json +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/__main__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/auth.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/cli.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/dataclasses.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/journald2aws/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/journald2aws/__main__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/journald2aws/cursor.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/journald2aws/driver.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/journald2aws/main.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/journald2aws/poster.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/logs.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/aws/metadata.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/gcp/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/clouds/gcp/auth.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/cmds.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/configs.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/journald/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/journald/fields.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/journald/genmessages.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/journald/messages.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/journald/tailer.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/__main__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/bootstrap.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/bootstrap_.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/commands/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/commands/base.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/commands/inject.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/commands/local.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/commands/marshal.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/commands/ping.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/commands/subprocess.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/commands/types.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/config.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/conf/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/conf/inject.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/config.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/git.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/inject_.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/interp.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/paths/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/paths/inject.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/paths/manager.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/paths/owners.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/paths/specs.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/paths/types.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/tmp.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/deploy/types.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/inject.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/main.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/marshal.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/remote/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/remote/_main.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/remote/channel.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/remote/config.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/remote/connection.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/remote/execution.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/remote/inject.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/remote/payload.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/remote/spawning.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/system/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/system/commands.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/system/config.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/system/inject.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/system/packages.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/system/platforms.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/targets/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/targets/bestpython.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/targets/bestpython.sh +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/targets/connection.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/targets/inject.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/manage/targets/targets.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/pyremote.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/scripts/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/scripts/journald2aws.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/scripts/supervisor.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/ssh.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/LICENSE.txt +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/__main__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/configs.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/dispatchers.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/dispatchersimpl.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/events.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/exceptions.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/groups.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/groupsimpl.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/http.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/inject.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/io.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/main.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/pipes.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/privileges.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/process.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/processimpl.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/setup.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/setupimpl.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/signals.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/spawning.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/spawningimpl.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/states.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/supervisor.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/types.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/utils/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/utils/collections.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/utils/diag.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/utils/fds.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/utils/fs.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/utils/os.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/utils/ostypes.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/utils/signals.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/utils/strings.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/supervisor/utils/users.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/tailscale/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/tailscale/api.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/tailscale/cli.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/threadworkers.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/tools/__init__.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra/tools/listresources.py +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra.egg-info/dependency_links.txt +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra.egg-info/entry_points.txt +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/ominfra.egg-info/top_level.txt +0 -0
- {ominfra-0.0.0.dev189 → ominfra-0.0.0.dev191}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ominfra
|
3
|
-
Version: 0.0.0.
|
3
|
+
Version: 0.0.0.dev191
|
4
4
|
Summary: ominfra
|
5
5
|
Author: wrmsr
|
6
6
|
License: BSD-3-Clause
|
@@ -12,8 +12,9 @@ Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: Operating System :: POSIX
|
13
13
|
Requires-Python: >=3.12
|
14
14
|
License-File: LICENSE
|
15
|
-
Requires-Dist: omdev==0.0.0.
|
16
|
-
Requires-Dist: omlish==0.0.0.
|
15
|
+
Requires-Dist: omdev==0.0.0.dev191
|
16
|
+
Requires-Dist: omlish==0.0.0.dev191
|
17
|
+
Requires-Dist: omserv==0.0.0.dev191
|
17
18
|
Provides-Extra: all
|
18
19
|
Requires-Dist: paramiko~=3.5; extra == "all"
|
19
20
|
Requires-Dist: asyncssh~=2.18; extra == "all"
|
@@ -0,0 +1,198 @@
|
|
1
|
+
# ruff: noqa: UP006 UP007
|
2
|
+
import dataclasses as dc
|
3
|
+
import json
|
4
|
+
import os.path
|
5
|
+
import typing as ta
|
6
|
+
|
7
|
+
from omlish.lite.cached import cached_nullary
|
8
|
+
from omlish.lite.check import check
|
9
|
+
from omlish.lite.json import json_dumps_pretty
|
10
|
+
from omlish.lite.marshal import ObjMarshalerManager
|
11
|
+
|
12
|
+
from .conf.manager import DeployConfManager
|
13
|
+
from .git import DeployGitManager
|
14
|
+
from .paths.owners import DeployPathOwner
|
15
|
+
from .paths.paths import DeployPath
|
16
|
+
from .specs import DeployAppSpec
|
17
|
+
from .tags import DeployAppRev
|
18
|
+
from .tags import DeployTagMap
|
19
|
+
from .types import DeployHome
|
20
|
+
from .venvs import DeployVenvManager
|
21
|
+
|
22
|
+
|
23
|
+
class DeployAppManager(DeployPathOwner):
|
24
|
+
def __init__(
|
25
|
+
self,
|
26
|
+
*,
|
27
|
+
git: DeployGitManager,
|
28
|
+
venvs: DeployVenvManager,
|
29
|
+
conf: DeployConfManager,
|
30
|
+
|
31
|
+
msh: ObjMarshalerManager,
|
32
|
+
) -> None:
|
33
|
+
super().__init__()
|
34
|
+
|
35
|
+
self._git = git
|
36
|
+
self._venvs = venvs
|
37
|
+
self._conf = conf
|
38
|
+
|
39
|
+
self._msh = msh
|
40
|
+
|
41
|
+
#
|
42
|
+
|
43
|
+
APP_DIR = DeployPath.parse('apps/@app/@time--@app-rev--@app-key/')
|
44
|
+
|
45
|
+
@cached_nullary
|
46
|
+
def get_owned_deploy_paths(self) -> ta.AbstractSet[DeployPath]:
|
47
|
+
return {
|
48
|
+
self.APP_DIR,
|
49
|
+
|
50
|
+
*[
|
51
|
+
DeployPath.parse(f'{self.APP_DIR}{sfx}/')
|
52
|
+
for sfx in [
|
53
|
+
'conf',
|
54
|
+
'git',
|
55
|
+
'venv',
|
56
|
+
]
|
57
|
+
],
|
58
|
+
}
|
59
|
+
|
60
|
+
#
|
61
|
+
|
62
|
+
def _make_tags(self, spec: DeployAppSpec) -> DeployTagMap:
|
63
|
+
return DeployTagMap(
|
64
|
+
spec.app,
|
65
|
+
spec.key(),
|
66
|
+
DeployAppRev(spec.git.rev),
|
67
|
+
)
|
68
|
+
|
69
|
+
#
|
70
|
+
|
71
|
+
@dc.dataclass(frozen=True)
|
72
|
+
class PreparedApp:
|
73
|
+
spec: DeployAppSpec
|
74
|
+
tags: DeployTagMap
|
75
|
+
|
76
|
+
dir: str
|
77
|
+
|
78
|
+
git_dir: ta.Optional[str] = None
|
79
|
+
venv_dir: ta.Optional[str] = None
|
80
|
+
conf_dir: ta.Optional[str] = None
|
81
|
+
|
82
|
+
async def prepare_app(
|
83
|
+
self,
|
84
|
+
spec: DeployAppSpec,
|
85
|
+
home: DeployHome,
|
86
|
+
tags: DeployTagMap,
|
87
|
+
) -> PreparedApp:
|
88
|
+
spec_json = json_dumps_pretty(self._msh.marshal_obj(spec))
|
89
|
+
|
90
|
+
#
|
91
|
+
|
92
|
+
app_tags = tags.add(*self._make_tags(spec))
|
93
|
+
|
94
|
+
#
|
95
|
+
|
96
|
+
check.non_empty_str(home)
|
97
|
+
|
98
|
+
app_dir = os.path.join(home, self.APP_DIR.render(app_tags))
|
99
|
+
|
100
|
+
os.makedirs(app_dir, exist_ok=True)
|
101
|
+
|
102
|
+
#
|
103
|
+
|
104
|
+
rkw: ta.Dict[str, ta.Any] = dict(
|
105
|
+
spec=spec,
|
106
|
+
tags=app_tags,
|
107
|
+
|
108
|
+
dir=app_dir,
|
109
|
+
)
|
110
|
+
|
111
|
+
#
|
112
|
+
|
113
|
+
spec_file = os.path.join(app_dir, 'spec.json')
|
114
|
+
with open(spec_file, 'w') as f: # noqa
|
115
|
+
f.write(spec_json)
|
116
|
+
|
117
|
+
#
|
118
|
+
|
119
|
+
git_dir = os.path.join(app_dir, 'git')
|
120
|
+
rkw.update(git_dir=git_dir)
|
121
|
+
await self._git.checkout(
|
122
|
+
spec.git,
|
123
|
+
home,
|
124
|
+
git_dir,
|
125
|
+
)
|
126
|
+
|
127
|
+
#
|
128
|
+
|
129
|
+
if spec.venv is not None:
|
130
|
+
venv_dir = os.path.join(app_dir, 'venv')
|
131
|
+
rkw.update(venv_dir=venv_dir)
|
132
|
+
await self._venvs.setup_venv(
|
133
|
+
spec.venv,
|
134
|
+
git_dir,
|
135
|
+
venv_dir,
|
136
|
+
)
|
137
|
+
|
138
|
+
#
|
139
|
+
|
140
|
+
if spec.conf is not None:
|
141
|
+
conf_dir = os.path.join(app_dir, 'conf')
|
142
|
+
rkw.update(conf_dir=conf_dir)
|
143
|
+
await self._conf.write_app_conf(
|
144
|
+
spec.conf,
|
145
|
+
conf_dir,
|
146
|
+
)
|
147
|
+
|
148
|
+
#
|
149
|
+
|
150
|
+
return DeployAppManager.PreparedApp(**rkw)
|
151
|
+
|
152
|
+
async def prepare_app_link(
|
153
|
+
self,
|
154
|
+
tags: DeployTagMap,
|
155
|
+
app_dir: str,
|
156
|
+
) -> PreparedApp:
|
157
|
+
spec_file = os.path.join(app_dir, 'spec.json')
|
158
|
+
with open(spec_file) as f: # noqa
|
159
|
+
spec_json = f.read()
|
160
|
+
|
161
|
+
spec: DeployAppSpec = self._msh.unmarshal_obj(json.loads(spec_json), DeployAppSpec)
|
162
|
+
|
163
|
+
#
|
164
|
+
|
165
|
+
app_tags = tags.add(*self._make_tags(spec))
|
166
|
+
|
167
|
+
#
|
168
|
+
|
169
|
+
rkw: ta.Dict[str, ta.Any] = dict(
|
170
|
+
spec=spec,
|
171
|
+
tags=app_tags,
|
172
|
+
|
173
|
+
dir=app_dir,
|
174
|
+
)
|
175
|
+
|
176
|
+
#
|
177
|
+
|
178
|
+
git_dir = os.path.join(app_dir, 'git')
|
179
|
+
check.state(os.path.isdir(git_dir))
|
180
|
+
rkw.update(git_dir=git_dir)
|
181
|
+
|
182
|
+
#
|
183
|
+
|
184
|
+
if spec.venv is not None:
|
185
|
+
venv_dir = os.path.join(app_dir, 'venv')
|
186
|
+
check.state(os.path.isdir(venv_dir))
|
187
|
+
rkw.update(venv_dir=venv_dir)
|
188
|
+
|
189
|
+
#
|
190
|
+
|
191
|
+
if spec.conf is not None:
|
192
|
+
conf_dir = os.path.join(app_dir, 'conf')
|
193
|
+
check.state(os.path.isdir(conf_dir))
|
194
|
+
rkw.update(conf_dir=conf_dir)
|
195
|
+
|
196
|
+
#
|
197
|
+
|
198
|
+
return DeployAppManager.PreparedApp(**rkw)
|
@@ -16,6 +16,8 @@ TODO:
|
|
16
16
|
- some things (venvs) cannot be moved, thus the /deploy/venvs dir
|
17
17
|
- ** ensure (enforce) equivalent relpath nesting
|
18
18
|
"""
|
19
|
+
import collections.abc
|
20
|
+
import functools
|
19
21
|
import os.path
|
20
22
|
import typing as ta
|
21
23
|
|
@@ -24,6 +26,8 @@ from omlish.lite.json import json_dumps_pretty
|
|
24
26
|
from omlish.lite.strings import strip_with_newline
|
25
27
|
from omlish.os.paths import is_path_in_dir
|
26
28
|
from omlish.os.paths import relative_symlink
|
29
|
+
from omserv.nginx.configs import NginxConfigItems
|
30
|
+
from omserv.nginx.configs import render_nginx_config_str
|
27
31
|
|
28
32
|
from ....configs import render_ini_config
|
29
33
|
from ..paths.paths import DeployPath
|
@@ -37,19 +41,70 @@ from .specs import DeployAppConfLink
|
|
37
41
|
from .specs import DeployAppConfSpec
|
38
42
|
from .specs import IniDeployAppConfContent
|
39
43
|
from .specs import JsonDeployAppConfContent
|
44
|
+
from .specs import NginxDeployAppConfContent
|
40
45
|
from .specs import RawDeployAppConfContent
|
41
46
|
|
42
47
|
|
48
|
+
T = ta.TypeVar('T')
|
49
|
+
|
50
|
+
|
51
|
+
##
|
52
|
+
|
53
|
+
|
43
54
|
class DeployConfManager:
|
44
|
-
def
|
55
|
+
def _process_conf_content(
|
56
|
+
self,
|
57
|
+
content: T,
|
58
|
+
*,
|
59
|
+
str_processor: ta.Optional[ta.Callable[[str], str]] = None,
|
60
|
+
) -> T:
|
61
|
+
def rec(o):
|
62
|
+
if isinstance(o, str):
|
63
|
+
if str_processor is not None:
|
64
|
+
return type(o)(str_processor(o))
|
65
|
+
|
66
|
+
elif isinstance(o, collections.abc.Mapping):
|
67
|
+
return type(o)([ # type: ignore
|
68
|
+
(rec(k), rec(v))
|
69
|
+
for k, v in o.items()
|
70
|
+
])
|
71
|
+
|
72
|
+
elif isinstance(o, collections.abc.Iterable):
|
73
|
+
return type(o)([ # type: ignore
|
74
|
+
rec(e) for e in o
|
75
|
+
])
|
76
|
+
|
77
|
+
return o
|
78
|
+
|
79
|
+
return rec(content)
|
80
|
+
|
81
|
+
#
|
82
|
+
|
83
|
+
def _render_app_conf_content(
|
84
|
+
self,
|
85
|
+
ac: DeployAppConfContent,
|
86
|
+
*,
|
87
|
+
str_processor: ta.Optional[ta.Callable[[str], str]] = None,
|
88
|
+
) -> str:
|
89
|
+
pcc = functools.partial(
|
90
|
+
self._process_conf_content,
|
91
|
+
str_processor=str_processor,
|
92
|
+
)
|
93
|
+
|
45
94
|
if isinstance(ac, RawDeployAppConfContent):
|
46
|
-
return ac.body
|
95
|
+
return pcc(ac.body)
|
47
96
|
|
48
97
|
elif isinstance(ac, JsonDeployAppConfContent):
|
49
|
-
|
98
|
+
json_obj = pcc(ac.obj)
|
99
|
+
return strip_with_newline(json_dumps_pretty(json_obj))
|
50
100
|
|
51
101
|
elif isinstance(ac, IniDeployAppConfContent):
|
52
|
-
|
102
|
+
ini_sections = pcc(ac.sections)
|
103
|
+
return strip_with_newline(render_ini_config(ini_sections))
|
104
|
+
|
105
|
+
elif isinstance(ac, NginxDeployAppConfContent):
|
106
|
+
nginx_items = NginxConfigItems.of(pcc(ac.items))
|
107
|
+
return strip_with_newline(render_nginx_config_str(nginx_items))
|
53
108
|
|
54
109
|
else:
|
55
110
|
raise TypeError(ac)
|
@@ -58,17 +113,37 @@ class DeployConfManager:
|
|
58
113
|
self,
|
59
114
|
acf: DeployAppConfFile,
|
60
115
|
app_conf_dir: str,
|
116
|
+
*,
|
117
|
+
str_processor: ta.Optional[ta.Callable[[str], str]] = None,
|
61
118
|
) -> None:
|
62
119
|
conf_file = os.path.join(app_conf_dir, acf.path)
|
63
120
|
check.arg(is_path_in_dir(app_conf_dir, conf_file))
|
64
121
|
|
65
|
-
body = self._render_app_conf_content(
|
122
|
+
body = self._render_app_conf_content(
|
123
|
+
acf.content,
|
124
|
+
str_processor=str_processor,
|
125
|
+
)
|
66
126
|
|
67
127
|
os.makedirs(os.path.dirname(conf_file), exist_ok=True)
|
68
128
|
|
69
129
|
with open(conf_file, 'w') as f: # noqa
|
70
130
|
f.write(body)
|
71
131
|
|
132
|
+
async def write_app_conf(
|
133
|
+
self,
|
134
|
+
spec: DeployAppConfSpec,
|
135
|
+
app_conf_dir: str,
|
136
|
+
) -> None:
|
137
|
+
def process_str(s: str) -> str:
|
138
|
+
return s
|
139
|
+
|
140
|
+
for acf in spec.files or []:
|
141
|
+
await self._write_app_conf_file(
|
142
|
+
acf,
|
143
|
+
app_conf_dir,
|
144
|
+
str_processor=process_str,
|
145
|
+
)
|
146
|
+
|
72
147
|
#
|
73
148
|
|
74
149
|
class _ComputedConfLink(ta.NamedTuple):
|
@@ -178,23 +253,13 @@ class DeployConfManager:
|
|
178
253
|
make_dirs=True,
|
179
254
|
)
|
180
255
|
|
181
|
-
|
182
|
-
|
183
|
-
async def write_app_conf(
|
256
|
+
async def link_app_conf(
|
184
257
|
self,
|
185
258
|
spec: DeployAppConfSpec,
|
186
259
|
tags: DeployTagMap,
|
187
260
|
app_conf_dir: str,
|
188
261
|
conf_link_dir: str,
|
189
|
-
)
|
190
|
-
for acf in spec.files or []:
|
191
|
-
await self._write_app_conf_file(
|
192
|
-
acf,
|
193
|
-
app_conf_dir,
|
194
|
-
)
|
195
|
-
|
196
|
-
#
|
197
|
-
|
262
|
+
):
|
198
263
|
for link in spec.links or []:
|
199
264
|
await self._make_app_conf_link(
|
200
265
|
link,
|
@@ -44,6 +44,15 @@ class IniDeployAppConfContent(DeployAppConfContent):
|
|
44
44
|
sections: IniConfigSectionSettingsMap
|
45
45
|
|
46
46
|
|
47
|
+
#
|
48
|
+
|
49
|
+
|
50
|
+
@register_single_field_type_obj_marshaler('items')
|
51
|
+
@dc.dataclass(frozen=True)
|
52
|
+
class NginxDeployAppConfContent(DeployAppConfContent):
|
53
|
+
items: ta.Any
|
54
|
+
|
55
|
+
|
47
56
|
##
|
48
57
|
|
49
58
|
|