Skip to content

Commit

Permalink
Force container in lowercase for case-insensitive OS
Browse files Browse the repository at this point in the history
  • Loading branch information
Dramelac committed Jul 26, 2023
1 parent e2cfedf commit 2b449bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions exegol/model/ExegolContainerTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from rich.prompt import Prompt

from exegol.config.EnvInfo import EnvInfo
from exegol.model.ContainerConfig import ContainerConfig
from exegol.model.ExegolImage import ExegolImage

Expand All @@ -14,6 +15,9 @@ def __init__(self, name: Optional[str], config: ContainerConfig, image: ExegolIm
if name is None:
name = Prompt.ask("[bold blue][?][/bold blue] Enter the name of your new exegol container", default="default")
assert name is not None
if EnvInfo.isWindowsHost() or EnvInfo.isMacHost():
# Force container as lowercase because the filesystem of windows / mac are case-insensitive => https://github.com/ThePorgs/Exegol/issues/167
name = name.lower()
self.container_name: str = name if name.startswith("exegol-") else f'exegol-{name}'
self.name: str = name.replace('exegol-', '')
if hostname:
Expand Down
7 changes: 7 additions & 0 deletions exegol/utils/DockerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ def getContainer(cls, tag: str) -> ExegolContainer:
return # type: ignore
# Check if there is at least 1 result. If no container was found, raise ObjectNotFound.
if container is None or len(container) == 0:
# Handle case-insensitive OS
if EnvInfo.isWindowsHost() or EnvInfo.isMacHost():
# First try to fetch the container as-is (for retroactive support with old container with uppercase characters)
# If the user's input didn't match any container, try to force the name in lowercase if not already tried
lowered_tag = tag.lower()
if lowered_tag != tag:
return cls.getContainer(lowered_tag)
raise ObjectNotFound
# Filter results with exact name matching
for c in container:
Expand Down

0 comments on commit 2b449bb

Please sign in to comment.