Skip to content

Commit

Permalink
Merge pull request #246 from ThePorgs/dev
Browse files Browse the repository at this point in the history
Release 4.3.9
  • Loading branch information
Dramelac authored Dec 17, 2024
2 parents ada0861 + 25b1554 commit 040a170
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 17 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.9"

# 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
38 changes: 27 additions & 11 deletions exegol/config/EnvInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,30 +194,44 @@ 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:
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}")
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 {}

@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:
Expand All @@ -226,7 +240,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
2 changes: 1 addition & 1 deletion exegol/manager/ExegolManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions exegol/utils/DataFileUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
2 changes: 1 addition & 1 deletion exegol/utils/GuiUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 040a170

Please sign in to comment.