Skip to content

Commit

Permalink
Update docker desktop new settings path
Browse files Browse the repository at this point in the history
  • Loading branch information
Dramelac committed Dec 16, 2024
1 parent b017560 commit 2b9579a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
6 changes: 3 additions & 3 deletions exegol/config/ConstantConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand All @@ -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()
Expand Down
29 changes: 20 additions & 9 deletions exegol/config/EnvInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down

0 comments on commit 2b9579a

Please sign in to comment.