From b017560edb2af08675fac91a3a225119f4fb619d Mon Sep 17 00:00:00 2001 From: Dramelac Date: Sun, 1 Dec 2024 19:43:25 +0100 Subject: [PATCH 1/4] Enable desktop if custom config is set --- exegol/manager/ExegolManager.py | 2 +- exegol/utils/DataFileUtils.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/exegol/manager/ExegolManager.py b/exegol/manager/ExegolManager.py index 8c81f700..f609a8e9 100644 --- a/exegol/manager/ExegolManager.py +++ b/exegol/manager/ExegolManager.py @@ -486,7 +486,7 @@ def __prepareContainerConfig(cls): if ParametersManager().envs is not None: for env in ParametersManager().envs: config.addRawEnv(env) - if UserConfig().desktop_default_enable ^ ParametersManager().desktop: + if (UserConfig().desktop_default_enable ^ ParametersManager().desktop) or ParametersManager().desktop_config != "": config.enableDesktop(ParametersManager().desktop_config) if ParametersManager().comment: config.addComment(ParametersManager().comment) diff --git a/exegol/utils/DataFileUtils.py b/exegol/utils/DataFileUtils.py index 7ab6a46a..d6c4ca51 100644 --- a/exegol/utils/DataFileUtils.py +++ b/exegol/utils/DataFileUtils.py @@ -80,6 +80,8 @@ def _create_config_file(self): os.chown(self._file_path, user_uid, user_gid) except PermissionError as e: logger.critical(f"Unable to open the file '{self._file_path}' ({e}). Please fix your file permissions or run exegol with the correct rights.") + except OSError as e: + logger.critical(f"A critical error occurred while interacting with filesystem: [{type(e)}] {e}") def _parse_config(self): data: Dict = {} From 2b9579a04aa7e52b2bbf3dcc7df665657ee09db4 Mon Sep 17 00:00:00 2001 From: Dramelac Date: Mon, 16 Dec 2024 15:31:14 +0100 Subject: [PATCH 2/4] Update docker desktop new settings path --- exegol/config/ConstantConfig.py | 6 +++--- exegol/config/EnvInfo.py | 29 ++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/exegol/config/ConstantConfig.py b/exegol/config/ConstantConfig.py index b8032413..b9f97567 100644 --- a/exegol/config/ConstantConfig.py +++ b/exegol/config/ConstantConfig.py @@ -5,7 +5,7 @@ class ConstantConfig: """Constant parameters information""" # Exegol Version - version: str = "4.3.8" + version: str = "4.3.9b1" # Exegol documentation link documentation: str = "https://exegol.rtfd.io/" @@ -22,8 +22,8 @@ class ConstantConfig: # Exegol config directory exegol_config_path: Path = Path().home() / ".exegol" # Docker Desktop for mac config file - docker_desktop_mac_config_path = Path().home() / "Library/Group Containers/group.com.docker/settings.json" - docker_desktop_windows_config_short_path = "AppData/Roaming/Docker/settings.json" + docker_desktop_mac_config_path = Path().home() / "Library/Group Containers/group.com.docker" + docker_desktop_windows_config_short_path = "AppData/Roaming/Docker" docker_desktop_windows_config_path = Path().home() / docker_desktop_windows_config_short_path # Install mode, check if Exegol has been git cloned or installed using pip package git_source_installation: bool = (src_root_path_obj / '.git').is_dir() diff --git a/exegol/config/EnvInfo.py b/exegol/config/EnvInfo.py index 8b9842fb..0a46f899 100644 --- a/exegol/config/EnvInfo.py +++ b/exegol/config/EnvInfo.py @@ -194,23 +194,34 @@ def getDockerDesktopSettings(cls) -> Dict: """Applicable only for docker desktop on macos""" if cls.isDockerDesktop(): if cls.__docker_desktop_resource_config is None: + dir_path = None + file_path = None if cls.is_mac_shell: - path = ConstantConfig.docker_desktop_mac_config_path + # Mac PATH + dir_path = ConstantConfig.docker_desktop_mac_config_path elif cls.is_windows_shell: - path = ConstantConfig.docker_desktop_windows_config_path + # Windows PATH + dir_path = ConstantConfig.docker_desktop_windows_config_path else: + # Windows PATH from WSL shell # Find docker desktop config - config_file = list(Path("/mnt/c/Users").glob(f"*/{ConstantConfig.docker_desktop_windows_config_short_path}")) + config_file = list(Path("/mnt/c/Users").glob(f"*/{ConstantConfig.docker_desktop_windows_config_short_path}/settings-store.json")) if len(config_file) == 0: - return {} - else: - path = config_file[0] - logger.debug(f"Docker desktop config found at {path}") + # Testing with legacy file name + config_file = list(Path("/mnt/c/Users").glob(f"*/{ConstantConfig.docker_desktop_windows_config_short_path}/settings.json")) + if len(config_file) == 0: + logger.warning(f"No docker desktop settings file found.") + return {} + file_path = config_file[0] + if file_path is None: + # Try to find settings file with new filename or fallback to legacy filename for Docker Desktop older than 4.34 + file_path = (dir_path / "settings-store.json") if (dir_path / "settings-store.json").is_file() else (dir_path / "settings.json") + logger.debug(f"Docker desktop config found at {file_path}") try: - with open(path, 'r') as docker_desktop_config: + with open(file_path, 'r') as docker_desktop_config: cls.__docker_desktop_resource_config = json.load(docker_desktop_config) except FileNotFoundError: - logger.warning(f"Docker Desktop configuration file not found: '{path}'") + logger.warning(f"Docker Desktop configuration file not found: '{file_path}'") return {} return cls.__docker_desktop_resource_config return {} From f6878973d9de6a49839fd162381744277664b090 Mon Sep 17 00:00:00 2001 From: Dramelac Date: Tue, 17 Dec 2024 19:01:22 +0100 Subject: [PATCH 3/4] Update docker desktop new settings keys --- exegol/config/EnvInfo.py | 10 +++++++--- exegol/utils/GuiUtils.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/exegol/config/EnvInfo.py b/exegol/config/EnvInfo.py index 0a46f899..a8a2fb88 100644 --- a/exegol/config/EnvInfo.py +++ b/exegol/config/EnvInfo.py @@ -216,7 +216,7 @@ def getDockerDesktopSettings(cls) -> Dict: if file_path is None: # Try to find settings file with new filename or fallback to legacy filename for Docker Desktop older than 4.34 file_path = (dir_path / "settings-store.json") if (dir_path / "settings-store.json").is_file() else (dir_path / "settings.json") - logger.debug(f"Docker desktop config found at {file_path}") + logger.debug(f"Loading Docker Desktop config from {file_path}") try: with open(file_path, 'r') as docker_desktop_config: cls.__docker_desktop_resource_config = json.load(docker_desktop_config) @@ -228,7 +228,9 @@ def getDockerDesktopSettings(cls) -> Dict: @classmethod def getDockerDesktopResources(cls) -> List[str]: - return cls.getDockerDesktopSettings().get('filesharingDirectories', []) + settings = cls.getDockerDesktopSettings() + # Handle legacy settings key + return settings.get('FilesharingDirectories', settings.get('filesharingDirectories', [])) @classmethod def isHostNetworkAvailable(cls) -> bool: @@ -237,7 +239,9 @@ def isHostNetworkAvailable(cls) -> bool: elif cls.isOrbstack(): return True elif cls.isDockerDesktop(): - res = cls.getDockerDesktopSettings().get('hostNetworkingEnabled', False) + settings = cls.getDockerDesktopSettings() + # Handle legacy settings key + res = settings.get('HostNetworkingEnabled', settings.get('hostNetworkingEnabled', False)) return res if res is not None else False logger.warning("Unknown or not supported environment for host network mode.") return False diff --git a/exegol/utils/GuiUtils.py b/exegol/utils/GuiUtils.py index 47ccc741..61d11056 100644 --- a/exegol/utils/GuiUtils.py +++ b/exegol/utils/GuiUtils.py @@ -418,7 +418,7 @@ def __create_default_wsl(cls) -> bool: pass # Check if docker have default docker integration docker_settings = EnvInfo.getDockerDesktopSettings() - if docker_settings is not None and docker_settings.get("enableIntegrationWithDefaultWslDistro", False): + if docker_settings is not None and docker_settings.get("EnableIntegrationWithDefaultWslDistro", docker_settings.get("enableIntegrationWithDefaultWslDistro", False)): logger.verbose("Set WSL Ubuntu as default to automatically enable docker integration") logger.debug("Running: C:\\Windows\\system32\\wsl.exe -s Ubuntu") # Set new WSL distribution as default to start it and enable docker integration From 25b155474efae554de174307139854334f4cdea1 Mon Sep 17 00:00:00 2001 From: Dramelac Date: Tue, 17 Dec 2024 22:49:21 +0100 Subject: [PATCH 4/4] New release --- exegol-resources | 2 +- exegol/config/ConstantConfig.py | 2 +- exegol/config/EnvInfo.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/exegol-resources b/exegol-resources index a6e78aad..27b2d1a8 160000 --- a/exegol-resources +++ b/exegol-resources @@ -1 +1 @@ -Subproject commit a6e78aade01083c4f50d3d5f0d55b8584d8cd7f0 +Subproject commit 27b2d1a83e30953418497fe889340d7afdab3fb9 diff --git a/exegol/config/ConstantConfig.py b/exegol/config/ConstantConfig.py index b9f97567..f6516f56 100644 --- a/exegol/config/ConstantConfig.py +++ b/exegol/config/ConstantConfig.py @@ -5,7 +5,7 @@ class ConstantConfig: """Constant parameters information""" # Exegol Version - version: str = "4.3.9b1" + version: str = "4.3.9" # Exegol documentation link documentation: str = "https://exegol.rtfd.io/" diff --git a/exegol/config/EnvInfo.py b/exegol/config/EnvInfo.py index a8a2fb88..15a09de4 100644 --- a/exegol/config/EnvInfo.py +++ b/exegol/config/EnvInfo.py @@ -214,6 +214,7 @@ def getDockerDesktopSettings(cls) -> Dict: return {} file_path = config_file[0] if file_path is None: + assert dir_path is not None # Try to find settings file with new filename or fallback to legacy filename for Docker Desktop older than 4.34 file_path = (dir_path / "settings-store.json") if (dir_path / "settings-store.json").is_file() else (dir_path / "settings.json") logger.debug(f"Loading Docker Desktop config from {file_path}")