app_deploy: add support for web types
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
55454a300e
commit
8010c51521
|
@ -38,10 +38,12 @@ if TYPE_CHECKING:
|
|||
MIN_PIP_VERSION = (23, 3, 2)
|
||||
|
||||
SUPPORTED_CHANNELS = {
|
||||
AppType.WEB: [Channel.STABLE, Channel.BETA],
|
||||
AppType.ZIP: [Channel.STABLE, Channel.BETA],
|
||||
AppType.GIT_REPO: list(Channel)
|
||||
}
|
||||
TYPE_TO_CHANNEL = {
|
||||
AppType.WEB: Channel.STABLE,
|
||||
AppType.ZIP: Channel.STABLE,
|
||||
AppType.GIT_REPO: Channel.DEV
|
||||
}
|
||||
|
@ -89,48 +91,12 @@ class AppDeploy(BaseDeploy):
|
|||
self.system_deps_json: Optional[pathlib.Path] = None
|
||||
self.info_tags: List[str] = config.getlist("info_tags", [])
|
||||
self.managed_services: List[str] = []
|
||||
svc_default = []
|
||||
if config.getboolean("is_system_service", True):
|
||||
svc_default.append(self.name)
|
||||
svc_choices = [self.name, "klipper", "moonraker"]
|
||||
services: List[str] = config.getlist(
|
||||
"managed_services", svc_default, separator=None
|
||||
)
|
||||
if self.name in services:
|
||||
machine: Machine = self.server.lookup_component("machine")
|
||||
data_path: str = self.server.get_app_args()["data_path"]
|
||||
asvc = pathlib.Path(data_path).joinpath("moonraker.asvc")
|
||||
if not machine.is_service_allowed(self.name):
|
||||
self.server.add_warning(
|
||||
f"[{config.get_name()}]: Moonraker is not permitted to "
|
||||
f"restart service '{self.name}'. To enable management "
|
||||
f"of this service add {self.name} to the bottom of the "
|
||||
f"file {asvc}. To disable management for this service "
|
||||
"set 'is_system_service: False' in the configuration "
|
||||
"for this section."
|
||||
)
|
||||
services.clear()
|
||||
for svc in services:
|
||||
if svc not in svc_choices:
|
||||
raw = " ".join(services)
|
||||
self.server.add_warning(
|
||||
f"[{config.get_name()}]: Option 'managed_services: {raw}' "
|
||||
f"contains an invalid value '{svc}'. All values must be "
|
||||
f"one of the following choices: {svc_choices}"
|
||||
)
|
||||
break
|
||||
for svc in svc_choices:
|
||||
if svc in services and svc not in self.managed_services:
|
||||
self.managed_services.append(svc)
|
||||
logging.debug(
|
||||
f"Extension {self.name} managed services: {self.managed_services}"
|
||||
)
|
||||
|
||||
def _configure_path(self, config: ConfigHelper) -> None:
|
||||
def _configure_path(self, config: ConfigHelper, reserve: bool = True) -> None:
|
||||
self.path = pathlib.Path(config.get('path')).expanduser().resolve()
|
||||
self._verify_path(config, 'path', self.path, check_file=False)
|
||||
if (
|
||||
self.name not in ["moonraker", "klipper"]
|
||||
reserve and self.name not in ["moonraker", "klipper"]
|
||||
and not self.path.joinpath(".writeable").is_file()
|
||||
):
|
||||
fm: FileManager = self.server.lookup_component("file_manager")
|
||||
|
@ -139,7 +105,9 @@ class AppDeploy(BaseDeploy):
|
|||
def _configure_virtualenv(self, config: ConfigHelper) -> None:
|
||||
venv_path: Optional[pathlib.Path] = None
|
||||
if config.has_option("virtualenv"):
|
||||
venv_path = pathlib.Path(config.get("virtualenv")).expanduser().resolve()
|
||||
venv_path = pathlib.Path(config.get("virtualenv")).expanduser()
|
||||
if not venv_path.is_absolute():
|
||||
venv_path = self.path.joinpath(venv_path)
|
||||
self._verify_path(config, 'virtualenv', venv_path, check_file=False)
|
||||
elif config.has_option("env"):
|
||||
# Deprecated
|
||||
|
@ -196,6 +164,44 @@ class AppDeploy(BaseDeploy):
|
|||
self.install_script = self.path.joinpath(install_script).resolve()
|
||||
self._verify_path(config, 'install_script', self.install_script)
|
||||
|
||||
def _configure_managed_services(self, config: ConfigHelper) -> None:
|
||||
svc_default = []
|
||||
if config.getboolean("is_system_service", True):
|
||||
svc_default.append(self.name)
|
||||
svc_choices = [self.name, "klipper", "moonraker"]
|
||||
services: List[str] = config.getlist(
|
||||
"managed_services", svc_default, separator=None
|
||||
)
|
||||
if self.name in services:
|
||||
machine: Machine = self.server.lookup_component("machine")
|
||||
data_path: str = self.server.get_app_args()["data_path"]
|
||||
asvc = pathlib.Path(data_path).joinpath("moonraker.asvc")
|
||||
if not machine.is_service_allowed(self.name):
|
||||
self.server.add_warning(
|
||||
f"[{config.get_name()}]: Moonraker is not permitted to "
|
||||
f"restart service '{self.name}'. To enable management "
|
||||
f"of this service add {self.name} to the bottom of the "
|
||||
f"file {asvc}. To disable management for this service "
|
||||
"set 'is_system_service: False' in the configuration "
|
||||
"for this section."
|
||||
)
|
||||
services.clear()
|
||||
for svc in services:
|
||||
if svc not in svc_choices:
|
||||
raw = " ".join(services)
|
||||
self.server.add_warning(
|
||||
f"[{config.get_name()}]: Option 'managed_services: {raw}' "
|
||||
f"contains an invalid value '{svc}'. All values must be "
|
||||
f"one of the following choices: {svc_choices}"
|
||||
)
|
||||
break
|
||||
for svc in svc_choices:
|
||||
if svc in services and svc not in self.managed_services:
|
||||
self.managed_services.append(svc)
|
||||
self.log_debug(
|
||||
f"Managed services: {self.managed_services}"
|
||||
)
|
||||
|
||||
def _verify_path(
|
||||
self,
|
||||
config: ConfigHelper,
|
||||
|
@ -217,7 +223,6 @@ class AppDeploy(BaseDeploy):
|
|||
|
||||
async def initialize(self) -> Dict[str, Any]:
|
||||
storage = await super().initialize()
|
||||
self._is_valid = storage.get("is_valid", False)
|
||||
self.pip_version = tuple(storage.get("pip_version", []))
|
||||
if self.pip_version:
|
||||
ver_str = ".".join([str(part) for part in self.pip_version])
|
||||
|
|
|
@ -36,6 +36,7 @@ class GitDeploy(AppDeploy):
|
|||
self._configure_path(config)
|
||||
self._configure_virtualenv(config)
|
||||
self._configure_dependencies(config)
|
||||
self._configure_managed_services(config)
|
||||
self.origin: str = config.get('origin')
|
||||
self.moved_origin: Optional[str] = config.get('moved_origin', None)
|
||||
self.primary_branch = config.get("primary_branch", "master")
|
||||
|
|
|
@ -41,6 +41,7 @@ class ZipDeploy(AppDeploy):
|
|||
if self.type == AppType.ZIP:
|
||||
self._configure_virtualenv(config)
|
||||
self._configure_dependencies(config)
|
||||
self._configure_managed_services(config)
|
||||
elif self.type == AppType.WEB:
|
||||
self.prefix = f"Web Client {self.name}: "
|
||||
self.repo = config.get('repo').strip().strip("/")
|
||||
|
|
Loading…
Reference in New Issue