From 2b9579a04aa7e52b2bbf3dcc7df665657ee09db4 Mon Sep 17 00:00:00 2001 From: Dramelac Date: Mon, 16 Dec 2024 15:31:14 +0100 Subject: [PATCH] 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 {}