Skip to content

Commit

Permalink
add podman compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Ulvé <[email protected]>
  • Loading branch information
florentulve committed Nov 30, 2023
1 parent 1472d35 commit 9f37180
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions exegol/config/ConstantConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ConstantConfig:
DOCKER_HUB: str = "hub.docker.com" # Don't handle docker login operations
DOCKER_REGISTRY: str = "registry-1.docker.io" # Don't handle docker login operations
IMAGE_NAME: str = "nwodtuhs/exegol"
IMAGE_FULL_NAME: str = "docker.io/nwodtuhs/exegol"
GITHUB_REPO: str = "ThePorgs/Exegol"
# Docker volume names (no docker volume used at this moment)
# Resources repository
Expand Down
11 changes: 7 additions & 4 deletions exegol/model/ExegolImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __initFromDockerImage(self):
self.__name = ""
for repo_tag in self.__image.attrs["RepoTags"]:
repo, name = repo_tag.split(':')
if not repo.startswith(ConstantConfig.IMAGE_NAME):
if not repo.startswith(ConstantConfig.IMAGE_NAME) and not repo.startswith(ConstantConfig.IMAGE_FULL_NAME):
# Ignoring external images (set container using external image as outdated)
continue
version_parsed = MetaImages.tagNameParsing(name)
Expand Down Expand Up @@ -534,10 +534,13 @@ def __setDigest(self, digest: Optional[str]):
def __parseDigest(docker_image: Image) -> str:
"""Parse the remote image digest ID.
Return digest id from the docker object."""

"""Unlike Docker, podman often fill RepoDigests with multiple values, we keep the last one which seems to match the digest attr"""
last_digest = ""
for digest_id in docker_image.attrs["RepoDigests"]:
if digest_id.startswith(ConstantConfig.IMAGE_NAME): # Find digest id from the right repository
return digest_id.split('@')[1]
return ""
if digest_id.startswith(ConstantConfig.IMAGE_NAME) or digest_id.startswith(ConstantConfig.IMAGE_FULL_NAME) : # Find digest id from the right repository
last_digest = digest_id.split('@')[1]
return last_digest

def getRemoteId(self) -> str:
"""Remote digest getter"""
Expand Down
11 changes: 8 additions & 3 deletions exegol/utils/DockerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ def createContainer(cls, model: ExegolContainerTemplate, temporary: bool = False
"stdin_open": model.config.interactive,
"tty": model.config.tty,
"mounts": model.config.getVolumes(),
"working_dir": model.config.getWorkingDir()}
"working_dir": model.config.getWorkingDir(),
"security_opt" : ["label=disable"]
}
if temporary:
# Only the 'run' function support the "remove" parameter
docker_create_function = cls.__client.containers.run
Expand Down Expand Up @@ -341,9 +343,12 @@ def __listLocalImages(cls, tag: Optional[str] = None) -> List[Image]:
result = []
ids = set()
for img in images:
repoTaglist = [repo_tag.split(':')[0] for repo_tag in img.attrs.get("RepoTags", [])]
# len tags = 0 handle exegol <none> images (nightly image lost their tag after update)
if len(img.attrs.get('RepoTags', [])) == 0 or \
ConstantConfig.IMAGE_NAME in [repo_tag.split(':')[0] for repo_tag in img.attrs.get("RepoTags", [])]:
if len(img.attrs.get('RepoTags', [])) == 0 \
or ConstantConfig.IMAGE_NAME in repoTaglist \
or ConstantConfig.IMAGE_FULL_NAME in repoTaglist:

result.append(img)
ids.add(img.id)

Expand Down

0 comments on commit 9f37180

Please sign in to comment.