ominfra 0.0.0.dev177__tar.gz → 0.0.0.dev178__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. {ominfra-0.0.0.dev177/ominfra.egg-info → ominfra-0.0.0.dev178}/PKG-INFO +3 -3
  2. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/commands.py +4 -3
  3. ominfra-0.0.0.dev178/ominfra/manage/deploy/deploy.py +34 -0
  4. ominfra-0.0.0.dev177/ominfra/manage/deploy/deploy.py → ominfra-0.0.0.dev178/ominfra/manage/deploy/driver.py +19 -32
  5. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/inject.py +29 -0
  6. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/scripts/manage.py +280 -43
  7. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/scripts/supervisor.py +205 -11
  8. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178/ominfra.egg-info}/PKG-INFO +3 -3
  9. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra.egg-info/SOURCES.txt +1 -0
  10. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra.egg-info/requires.txt +2 -2
  11. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/pyproject.toml +3 -3
  12. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/LICENSE +0 -0
  13. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/MANIFEST.in +0 -0
  14. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/README.rst +0 -0
  15. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/.manifests.json +0 -0
  16. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/__about__.py +0 -0
  17. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/__init__.py +0 -0
  18. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/__init__.py +0 -0
  19. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/__init__.py +0 -0
  20. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/__main__.py +0 -0
  21. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/auth.py +0 -0
  22. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/cli.py +0 -0
  23. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/dataclasses.py +0 -0
  24. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/journald2aws/__init__.py +0 -0
  25. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/journald2aws/__main__.py +0 -0
  26. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/journald2aws/cursor.py +0 -0
  27. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/journald2aws/driver.py +0 -0
  28. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/journald2aws/main.py +0 -0
  29. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/journald2aws/poster.py +0 -0
  30. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/logs.py +0 -0
  31. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/aws/metadata.py +0 -0
  32. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/gcp/__init__.py +0 -0
  33. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/clouds/gcp/auth.py +0 -0
  34. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/cmds.py +0 -0
  35. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/configs.py +0 -0
  36. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/journald/__init__.py +0 -0
  37. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/journald/fields.py +0 -0
  38. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/journald/genmessages.py +0 -0
  39. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/journald/messages.py +0 -0
  40. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/journald/tailer.py +0 -0
  41. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/__init__.py +0 -0
  42. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/__main__.py +0 -0
  43. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/bootstrap.py +0 -0
  44. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/bootstrap_.py +0 -0
  45. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/commands/__init__.py +0 -0
  46. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/commands/base.py +0 -0
  47. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/commands/inject.py +0 -0
  48. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/commands/local.py +0 -0
  49. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/commands/marshal.py +0 -0
  50. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/commands/ping.py +0 -0
  51. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/commands/subprocess.py +0 -0
  52. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/commands/types.py +0 -0
  53. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/config.py +0 -0
  54. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/__init__.py +0 -0
  55. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/apps.py +0 -0
  56. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/conf.py +0 -0
  57. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/config.py +0 -0
  58. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/git.py +0 -0
  59. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/interp.py +0 -0
  60. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/paths/__init__.py +0 -0
  61. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/paths/inject.py +0 -0
  62. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/paths/manager.py +0 -0
  63. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/paths/owners.py +0 -0
  64. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/paths/paths.py +0 -0
  65. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/paths/types.py +0 -0
  66. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/specs.py +0 -0
  67. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/tags.py +0 -0
  68. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/tmp.py +0 -0
  69. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/types.py +0 -0
  70. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/deploy/venvs.py +0 -0
  71. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/inject.py +0 -0
  72. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/main.py +0 -0
  73. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/marshal.py +0 -0
  74. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/remote/__init__.py +0 -0
  75. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/remote/_main.py +0 -0
  76. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/remote/channel.py +0 -0
  77. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/remote/config.py +0 -0
  78. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/remote/connection.py +0 -0
  79. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/remote/execution.py +0 -0
  80. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/remote/inject.py +0 -0
  81. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/remote/payload.py +0 -0
  82. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/remote/spawning.py +0 -0
  83. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/system/__init__.py +0 -0
  84. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/system/commands.py +0 -0
  85. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/system/config.py +0 -0
  86. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/system/inject.py +0 -0
  87. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/system/packages.py +0 -0
  88. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/system/platforms.py +0 -0
  89. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/targets/__init__.py +0 -0
  90. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/targets/bestpython.py +0 -0
  91. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/targets/bestpython.sh +0 -0
  92. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/targets/connection.py +0 -0
  93. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/targets/inject.py +0 -0
  94. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/manage/targets/targets.py +0 -0
  95. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/pyremote.py +0 -0
  96. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/scripts/__init__.py +0 -0
  97. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/scripts/journald2aws.py +0 -0
  98. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/ssh.py +0 -0
  99. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/LICENSE.txt +0 -0
  100. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/__init__.py +0 -0
  101. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/__main__.py +0 -0
  102. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/configs.py +0 -0
  103. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/dispatchers.py +0 -0
  104. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/dispatchersimpl.py +0 -0
  105. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/events.py +0 -0
  106. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/exceptions.py +0 -0
  107. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/groups.py +0 -0
  108. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/groupsimpl.py +0 -0
  109. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/http.py +0 -0
  110. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/inject.py +0 -0
  111. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/io.py +0 -0
  112. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/main.py +0 -0
  113. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/pipes.py +0 -0
  114. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/privileges.py +0 -0
  115. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/process.py +0 -0
  116. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/processimpl.py +0 -0
  117. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/setup.py +0 -0
  118. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/setupimpl.py +0 -0
  119. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/signals.py +0 -0
  120. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/spawning.py +0 -0
  121. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/spawningimpl.py +0 -0
  122. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/states.py +0 -0
  123. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/supervisor.py +0 -0
  124. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/types.py +0 -0
  125. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/utils/__init__.py +0 -0
  126. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/utils/collections.py +0 -0
  127. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/utils/diag.py +0 -0
  128. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/utils/fds.py +0 -0
  129. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/utils/fs.py +0 -0
  130. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/utils/os.py +0 -0
  131. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/utils/ostypes.py +0 -0
  132. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/utils/signals.py +0 -0
  133. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/utils/strings.py +0 -0
  134. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/supervisor/utils/users.py +0 -0
  135. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/tailscale/__init__.py +0 -0
  136. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/tailscale/api.py +0 -0
  137. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/tailscale/cli.py +0 -0
  138. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/threadworkers.py +0 -0
  139. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/tools/__init__.py +0 -0
  140. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra/tools/listresources.py +0 -0
  141. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra.egg-info/dependency_links.txt +0 -0
  142. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra.egg-info/entry_points.txt +0 -0
  143. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/ominfra.egg-info/top_level.txt +0 -0
  144. {ominfra-0.0.0.dev177 → ominfra-0.0.0.dev178}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ominfra
3
- Version: 0.0.0.dev177
3
+ Version: 0.0.0.dev178
4
4
  Summary: ominfra
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,8 +12,8 @@ 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.dev177
16
- Requires-Dist: omlish==0.0.0.dev177
15
+ Requires-Dist: omdev==0.0.0.dev178
16
+ Requires-Dist: omlish==0.0.0.dev178
17
17
  Provides-Extra: all
18
18
  Requires-Dist: paramiko~=3.5; extra == "all"
19
19
  Requires-Dist: asyncssh~=2.18; extra == "all"
@@ -5,7 +5,7 @@ from omlish.lite.logs import log
5
5
 
6
6
  from ..commands.base import Command
7
7
  from ..commands.base import CommandExecutor
8
- from .deploy import DeployManager
8
+ from .driver import DeployDriverFactory
9
9
  from .specs import DeploySpec
10
10
 
11
11
 
@@ -23,11 +23,12 @@ class DeployCommand(Command['DeployCommand.Output']):
23
23
 
24
24
  @dc.dataclass(frozen=True)
25
25
  class DeployCommandExecutor(CommandExecutor[DeployCommand, DeployCommand.Output]):
26
- _deploy: DeployManager
26
+ _driver_factory: DeployDriverFactory
27
27
 
28
28
  async def execute(self, cmd: DeployCommand) -> DeployCommand.Output:
29
29
  log.info('Deploying! %r', cmd.spec)
30
30
 
31
- await self._deploy.run_deploy(cmd.spec)
31
+ with self._driver_factory(cmd.spec) as driver:
32
+ await driver.drive_deploy()
32
33
 
33
34
  return DeployCommand.Output()
@@ -0,0 +1,34 @@
1
+ # ruff: noqa: UP006 UP007
2
+ import datetime
3
+ import typing as ta
4
+
5
+ from omlish.lite.typing import Func0
6
+
7
+ from .tags import DeployTime
8
+
9
+
10
+ DEPLOY_TAG_DATETIME_FMT = '%Y%m%dT%H%M%SZ'
11
+
12
+
13
+ DeployManagerUtcClock = ta.NewType('DeployManagerUtcClock', Func0[datetime.datetime])
14
+
15
+
16
+ class DeployManager:
17
+ def __init__(
18
+ self,
19
+ *,
20
+
21
+ utc_clock: ta.Optional[DeployManagerUtcClock] = None,
22
+ ):
23
+ super().__init__()
24
+
25
+ self._utc_clock = utc_clock
26
+
27
+ def _utc_now(self) -> datetime.datetime:
28
+ if self._utc_clock is not None:
29
+ return self._utc_clock() # noqa
30
+ else:
31
+ return datetime.datetime.now(tz=datetime.timezone.utc) # noqa
32
+
33
+ def make_deploy_time(self) -> DeployTime:
34
+ return DeployTime(self._utc_now().strftime(DEPLOY_TAG_DATETIME_FMT))
@@ -1,60 +1,47 @@
1
1
  # ruff: noqa: UP006 UP007
2
- import datetime
3
2
  import os.path
4
3
  import typing as ta
5
4
 
6
5
  from omlish.lite.check import check
7
- from omlish.lite.typing import Func0
6
+ from omlish.lite.typing import Func1
8
7
 
9
8
  from .apps import DeployAppManager
9
+ from .deploy import DeployManager
10
10
  from .paths.manager import DeployPathsManager
11
11
  from .specs import DeploySpec
12
12
  from .tags import DeployAppRev
13
13
  from .tags import DeployTagMap
14
- from .tags import DeployTime
15
14
  from .types import DeployHome
16
15
 
17
16
 
18
- DEPLOY_TAG_DATETIME_FMT = '%Y%m%dT%H%M%SZ'
17
+ class DeployDriverFactory(Func1[DeploySpec, ta.ContextManager['DeployDriver']]):
18
+ pass
19
19
 
20
20
 
21
- DeployManagerUtcClock = ta.NewType('DeployManagerUtcClock', Func0[datetime.datetime])
22
-
23
-
24
- class DeployManager:
21
+ class DeployDriver:
25
22
  def __init__(
26
23
  self,
27
24
  *,
28
- apps: DeployAppManager,
29
- paths: DeployPathsManager,
25
+ spec: DeploySpec,
30
26
 
31
- utc_clock: ta.Optional[DeployManagerUtcClock] = None,
32
- ):
27
+ deploys: DeployManager,
28
+ paths: DeployPathsManager,
29
+ apps: DeployAppManager,
30
+ ) -> None:
33
31
  super().__init__()
34
32
 
35
- self._apps = apps
36
- self._paths = paths
37
-
38
- self._utc_clock = utc_clock
33
+ self._spec = spec
39
34
 
40
- def _utc_now(self) -> datetime.datetime:
41
- if self._utc_clock is not None:
42
- return self._utc_clock() # noqa
43
- else:
44
- return datetime.datetime.now(tz=datetime.timezone.utc) # noqa
45
-
46
- def _make_deploy_time(self) -> DeployTime:
47
- return DeployTime(self._utc_now().strftime(DEPLOY_TAG_DATETIME_FMT))
35
+ self._deploys = deploys
36
+ self._paths = paths
37
+ self._apps = apps
48
38
 
49
- async def run_deploy(
50
- self,
51
- spec: DeploySpec,
52
- ) -> None:
39
+ async def drive_deploy(self) -> None:
53
40
  self._paths.validate_deploy_paths()
54
41
 
55
42
  #
56
43
 
57
- hs = check.non_empty_str(spec.home)
44
+ hs = check.non_empty_str(self._spec.home)
58
45
  hs = os.path.expanduser(hs)
59
46
  hs = os.path.realpath(hs)
60
47
  hs = os.path.abspath(hs)
@@ -64,13 +51,13 @@ class DeployManager:
64
51
  #
65
52
 
66
53
  deploy_tags = DeployTagMap(
67
- self._make_deploy_time(),
68
- spec.key(),
54
+ self._deploys.make_deploy_time(),
55
+ self._spec.key(),
69
56
  )
70
57
 
71
58
  #
72
59
 
73
- for app in spec.apps:
60
+ for app in self._spec.apps:
74
61
  app_tags = deploy_tags.add(
75
62
  app.app,
76
63
  app.key(),
@@ -1,6 +1,9 @@
1
1
  # ruff: noqa: UP006 UP007
2
+ import contextlib
2
3
  import typing as ta
3
4
 
5
+ from omlish.lite.inject import ContextvarInjectorScope
6
+ from omlish.lite.inject import Injector
4
7
  from omlish.lite.inject import InjectorBindingOrBindings
5
8
  from omlish.lite.inject import InjectorBindings
6
9
  from omlish.lite.inject import inj
@@ -12,16 +15,23 @@ from .commands import DeployCommandExecutor
12
15
  from .conf import DeployConfManager
13
16
  from .config import DeployConfig
14
17
  from .deploy import DeployManager
18
+ from .driver import DeployDriver
19
+ from .driver import DeployDriverFactory
15
20
  from .git import DeployGitManager
16
21
  from .interp import InterpCommand
17
22
  from .interp import InterpCommandExecutor
18
23
  from .paths.inject import bind_deploy_paths
19
24
  from .paths.owners import DeployPathOwner
25
+ from .specs import DeploySpec
20
26
  from .tmp import DeployHomeAtomics
21
27
  from .tmp import DeployTmpManager
22
28
  from .venvs import DeployVenvManager
23
29
 
24
30
 
31
+ class DeployInjectorScope(ContextvarInjectorScope):
32
+ pass
33
+
34
+
25
35
  def bind_deploy(
26
36
  *,
27
37
  deploy_config: DeployConfig,
@@ -65,6 +75,25 @@ def bind_deploy(
65
75
 
66
76
  #
67
77
 
78
+ def provide_deploy_driver_factory(injector: Injector, sc: DeployInjectorScope) -> DeployDriverFactory:
79
+ @contextlib.contextmanager
80
+ def factory(spec: DeploySpec) -> ta.Iterator[DeployDriver]:
81
+ with sc.enter({
82
+ inj.as_key(DeploySpec): spec,
83
+ }):
84
+ yield injector[DeployDriver]
85
+ return DeployDriverFactory(factory)
86
+ lst.append(inj.bind(provide_deploy_driver_factory, singleton=True))
87
+
88
+ lst.extend([
89
+ inj.bind_scope(DeployInjectorScope),
90
+ inj.bind_scope_seed(DeploySpec, DeployInjectorScope),
91
+
92
+ inj.bind(DeployDriver, in_=DeployInjectorScope),
93
+ ])
94
+
95
+ #
96
+
68
97
  lst.extend([
69
98
  bind_command(DeployCommand, DeployCommandExecutor),
70
99
  bind_command(InterpCommand, InterpCommandExecutor),