Skip to content

Commit

Permalink
Add config to disable exegol resources
Browse files Browse the repository at this point in the history
Signed-off-by: Dramelac <[email protected]>
  • Loading branch information
Dramelac committed Sep 9, 2024
1 parent 7a2fded commit bf1d6f5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
11 changes: 8 additions & 3 deletions exegol/config/UserConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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", {})
Expand All @@ -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)}",
Expand Down
7 changes: 5 additions & 2 deletions exegol/manager/UpdateManager.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion exegol/model/ContainerConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions exegol/model/ExegolModules.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit bf1d6f5

Please sign in to comment.