-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Transport Prefixes #133
base: main
Are you sure you want to change the base?
Conversation
I note that the format is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my suggestions
podman_hpc/podman_hpc.py
Outdated
|
||
# Check for transport_prefix | ||
if "://" in image: | ||
transport_prefix, image = image.split("://", 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the prefix isn't used, maybe replace this with just
if "://" in image:
image = image.split("://", 1)[0]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated this to check for the entire prefix
PODMAN_TRANSPORT_PREFIXES = [
"docker://",
"dir:",
"docker-archive:",
"docker-daemon:",
"oci-archive:",
]
# podman-hpc pull subcommand (modified) ####################################
@podhpc.command(
context_settings=dict(
ignore_unknown_options=True,
),
options_metavar="[options]",
)
@pass_siteconf
@click.pass_context
@click.argument("podman_args", nargs=-1, type=click.UNPROCESSED)
@click.argument("image")
def pull(ctx, siteconf, image, podman_args, **site_opts):
"""Pulls an image to a local repository and makes a squashed copy."""
cmd = [siteconf.podman_bin, "pull"]
cmd.extend(podman_args)
cmd.extend(siteconf.get_cmd_extensions("pull", site_opts))
cmd.append(image)
proc = Popen(cmd)
proc.communicate()
# Check for transport_prefix
for prefix in PODMAN_TRANSPORT_PREFIXES:
if image.startswith(prefix):
if prefix != "docker://":
sys.stderr.write(
f"""WARNING: Transport prefix '{prefix}' is
incompatible with podman-hpc.\n"""
)
image = image[len(prefix) :] # Remove the prefix
break
Thanks for the report and proposed fix. This looks good and this seems a reasonable place to handle it. Can you do a few minor things just to keep the flake8 happy. I'll add a few other minor comments and then we can merge it. |
Thanks for your feedback @scanon! I have included it in this commit. I tried running I have updated this PR to check for the entire prefix PODMAN_TRANSPORT_PREFIXES = [
"docker://",
"dir:",
"docker-archive:",
"docker-daemon:",
"oci-archive:",
]
# podman-hpc pull subcommand (modified) ####################################
@podhpc.command(
context_settings=dict(
ignore_unknown_options=True,
),
options_metavar="[options]",
)
@pass_siteconf
@click.pass_context
@click.argument("podman_args", nargs=-1, type=click.UNPROCESSED)
@click.argument("image")
def pull(ctx, siteconf, image, podman_args, **site_opts):
"""Pulls an image to a local repository and makes a squashed copy."""
cmd = [siteconf.podman_bin, "pull"]
cmd.extend(podman_args)
cmd.extend(siteconf.get_cmd_extensions("pull", site_opts))
cmd.append(image)
proc = Popen(cmd)
proc.communicate()
# Check for transport_prefix
for prefix in PODMAN_TRANSPORT_PREFIXES:
if image.startswith(prefix):
if prefix != "docker://":
sys.stderr.write(
f"""WARNING: Transport prefix '{prefix}' is
incompatible with podman-hpc.\n"""
)
image = image[len(prefix) :] # Remove the prefix
break This would only work with the |
For my reference, this is the OCI image specification for transport prefixes: https://github.com/containers/image/blob/main/docs/containers-transports.5.md#dockerdocker-reference |
There isn't a
CONTRIB.md
so I have created a fork and PR.Closes #132. TLDR: enables
podman-hpc pull docker://docker.io/library/ubuntu:latest
.I thought that simply adding this after the
podman pull
subprocess would do the job instead of updatingMigrateUtils()
.if proc.returncode == 0:
?podman-hpc
. If you would accept this change / or have feedback do let me know and I'll do some testing.