From bf1d6f5d6379069913fe28812f0e66cdb0828795 Mon Sep 17 00:00:00 2001 From: Dramelac Date: Tue, 10 Sep 2024 00:36:32 +0200 Subject: [PATCH] Add config to disable exegol resources Signed-off-by: Dramelac --- exegol/config/UserConfig.py | 11 ++++++++--- exegol/manager/UpdateManager.py | 7 +++++-- exegol/model/ContainerConfig.py | 3 ++- exegol/model/ExegolModules.py | 6 +++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/exegol/config/UserConfig.py b/exegol/config/UserConfig.py index d3a877aa..af38ee0e 100644 --- a/exegol/config/UserConfig.py +++ b/exegol/config/UserConfig.py @@ -24,6 +24,7 @@ def __init__(self): self.auto_remove_images: bool = True self.auto_update_workspace_fs: bool = False self.default_start_shell: str = "zsh" + self.enable_exegol_resources: bool = True self.shell_logging_method: str = "asciinema" self.shell_logging_compress: bool = True self.desktop_default_enable: bool = False @@ -61,6 +62,9 @@ def _build_file_content(self): # Default shell command to start default_start_shell: {self.default_start_shell} + # Enable Exegol resources + enable_exegol_resources: {self.enable_exegol_resources} + # Change the configuration of the shell logging functionality shell_logging: #Choice of the method used to record the sessions (script or asciinema) @@ -82,8 +86,6 @@ def _build_file_content(self): localhost_by_default: {self.desktop_default_localhost} """ - # TODO handle default image selection - # TODO handle default start container return config @staticmethod @@ -115,6 +117,7 @@ def _process_data(self): self.auto_remove_images = self._load_config_bool(config_data, 'auto_remove_image', self.auto_remove_images) self.auto_update_workspace_fs = self._load_config_bool(config_data, 'auto_update_workspace_fs', self.auto_update_workspace_fs) self.default_start_shell = self._load_config_str(config_data, 'default_start_shell', self.default_start_shell, choices=self.start_shell_options) + self.enable_exegol_resources = self._load_config_bool(config_data, 'enable_exegol_resources', self.enable_exegol_resources) # Shell_logging section shell_logging_data = config_data.get("shell_logging", {}) @@ -132,7 +135,9 @@ def get_configs(self) -> List[str]: configs = [ f"User config file: [magenta]{self._file_path}[/magenta]", f"Private workspace: [magenta]{self.private_volume_path}[/magenta]", - f"Exegol resources: [magenta]{self.exegol_resources_path}[/magenta]", + "Exegol resources: " + (f"[magenta]{self.exegol_resources_path}[/magenta]" + if self.enable_exegol_resources else + boolFormatter(self.enable_exegol_resources)), f"My resources: [magenta]{self.my_resources_path}[/magenta]", f"Auto-check updates: {boolFormatter(self.auto_check_updates)}", f"Auto-remove images: {boolFormatter(self.auto_remove_images)}", diff --git a/exegol/manager/UpdateManager.py b/exegol/manager/UpdateManager.py index 55626948..ef7fecde 100644 --- a/exegol/manager/UpdateManager.py +++ b/exegol/manager/UpdateManager.py @@ -1,12 +1,12 @@ import re -from datetime import datetime, timedelta +from pathlib import Path from typing import Optional, Dict, cast, Tuple, Sequence -from pathlib import Path, PurePath from rich.prompt import Prompt from exegol.config.ConstantConfig import ConstantConfig from exegol.config.DataCache import DataCache +from exegol.config.UserConfig import UserConfig from exegol.console.ExegolPrompt import Confirm from exegol.console.TUI import ExegolTUI from exegol.console.cli.ParametersManager import ParametersManager @@ -117,6 +117,9 @@ def updateImageSource(cls) -> bool: @classmethod def updateResources(cls) -> bool: """Update Exegol-resources from git (submodule)""" + if not UserConfig().enable_exegol_resources: + logger.info("Skipping disabled Exegol resources.") + return False try: if not ExegolModules().isExegolResourcesReady() and not Confirm('Do you want to update exegol resources.', default=True): return False diff --git a/exegol/model/ContainerConfig.py b/exegol/model/ContainerConfig.py index c34ba06b..8d16f8db 100644 --- a/exegol/model/ContainerConfig.py +++ b/exegol/model/ContainerConfig.py @@ -501,7 +501,8 @@ def enableExegolResources(self) -> bool: raise CancelOperation except CancelOperation: # Error during installation, skipping operation - logger.warning("Exegol resources have not been downloaded, the feature cannot be enabled") + if UserConfig().enable_exegol_resources: + logger.warning("Exegol resources have not been downloaded, the feature cannot be enabled yet") return False logger.verbose("Config: Enabling exegol resources volume") self.__exegol_resources = True diff --git a/exegol/model/ExegolModules.py b/exegol/model/ExegolModules.py index 95b6ba7e..794cb414 100644 --- a/exegol/model/ExegolModules.py +++ b/exegol/model/ExegolModules.py @@ -1,14 +1,14 @@ from pathlib import Path from typing import Optional, Union +from exegol.config.ConstantConfig import ConstantConfig +from exegol.config.UserConfig import UserConfig from exegol.console.ExegolPrompt import Confirm from exegol.console.cli.ParametersManager import ParametersManager from exegol.exceptions.ExegolExceptions import CancelOperation -from exegol.config.ConstantConfig import ConstantConfig from exegol.utils.ExeLog import logger from exegol.utils.GitUtils import GitUtils from exegol.utils.MetaSingleton import MetaSingleton -from exegol.config.UserConfig import UserConfig class ExegolModules(metaclass=MetaSingleton): @@ -51,7 +51,7 @@ def getResourcesGit(self, fast_load: bool = False, skip_install: bool = False) - if self.__git_resources is None: self.__git_resources = GitUtils(UserConfig().exegol_resources_path, "resources", "", skip_submodule_update=fast_load) - if not self.__git_resources.isAvailable and not skip_install: + if not self.__git_resources.isAvailable and not skip_install and UserConfig().enable_exegol_resources: self.__init_resources_repo() return self.__git_resources