Skip to content

Commit

Permalink
syscontainers: Use util.remove_skopeo_prefixes
Browse files Browse the repository at this point in the history
_get_skopeo_args now offloads removing of http:, https:, and oci: to
util.remove_skopeo_prefixes.

Closes: projectatomic#1114
Approved by: giuseppe
  • Loading branch information
ashcrow authored and eyusupov committed Mar 10, 2018
1 parent 914e122 commit 5a6b746
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Atomic/syscontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1703,18 +1703,27 @@ def _parse_imagename(imagename):
return reg, image, "latest"

def _get_skopeo_args(self, image, full_resolution=False):
insecure = "http:" in image
"""
Finds the real image name and if the registry is secure or not.
for i in ["oci:", "http:", "https:"]:
image = image.replace(i, "")
:param image: The image as given by the user.
:type image: str
:param full_resolution: If the image should be remotely resolved
:type full_resolution: bool
:returns: If the registry is secure and the real image name
:rtype: tuple(bool, str)
"""
# Remove prefixes which we use to map to skopeo args
real_image = util.remove_skopeo_prefixes(image)

if full_resolution:
try:
with AtomicDocker() as client:
image = util.find_remote_image(client, image) or image
real_image = util.find_remote_image(client, real_image) or real_image
except NoDockerDaemon:
pass
return insecure, image

return "http:" in image, real_image

def _convert_to_skopeo(self, image):
insecure, image = self._get_skopeo_args(image, full_resolution=True)
Expand Down

0 comments on commit 5a6b746

Please sign in to comment.