Podman,
check_container_engine,
find_container_engine,
+ pull_command,
registry_login,
)
from cephadmlib.data_utils import (
'Digest did not match, expected',
]
- cmd = [ctx.container_engine.path, 'pull', image]
- if isinstance(ctx.container_engine, Podman):
- if insecure:
- cmd.append('--tls-verify=false')
-
- if os.path.exists('/etc/ceph/podman-auth.json'):
- cmd.append('--authfile=/etc/ceph/podman-auth.json')
- cmd_str = ' '.join(cmd)
+ cmd = pull_command(ctx, image, insecure=insecure)
for sleep_secs in [1, 4, 25]:
out, err, ret = call(ctx, cmd, verbosity=CallVerbosity.QUIET_UNLESS_ERROR)
if 'unauthorized' in err:
raise UnauthorizedRegistryError()
+ cmd_str = ' '.join(cmd)
if not any(pattern in err for pattern in ignorelist):
raise Error('Failed command: %s' % cmd_str)
'Failed to login to custom registry @ %s as %s with given password'
% (ctx.registry_url, ctx.registry_username)
)
+
+
+def pull_command(
+ ctx: CephadmContext, image: str, insecure: bool = False
+) -> List[str]:
+ """Return a command that can be run to pull an image."""
+ cmd = [ctx.container_engine.path, 'pull', image]
+ if isinstance(ctx.container_engine, Podman):
+ if insecure:
+ cmd.append('--tls-verify=false')
+
+ if os.path.exists('/etc/ceph/podman-auth.json'):
+ cmd.append('--authfile=/etc/ceph/podman-auth.json')
+ return cmd