mirror of
https://github.com/libssh2/libssh2.git
synced 2026-10-24 03:48:58 +03:00
openssh_fixture: merge Apple container commands with others
Use the full `image pull`, `image tag` commands for docker and podman,
to make them all use the same commands.
Ref:
https://docs.docker.com/reference/cli/docker/image/pull/
https://docs.docker.com/reference/cli/docker/image/tag/
Follow-up to 9bd1f16dc2 #2605
Closes #2622
This commit is contained in:
@@ -172,28 +172,17 @@ static int build_openssh_server_container_image(void)
|
||||
if(container_cmd) {
|
||||
const char *container_image_name = openssh_server_image();
|
||||
if(container_image_name) {
|
||||
int ret;
|
||||
if(strstr(container_cmd, "container")) {
|
||||
/* Requires Apple container 0.7.0+ for '--progress none' */
|
||||
ret = run_command(NULL, "%s image pull --progress none %s",
|
||||
container_cmd, container_image_name);
|
||||
if(ret == 0) {
|
||||
ret = run_command(NULL, "%s image tag %s "
|
||||
"libssh2/openssh_server",
|
||||
container_cmd, container_image_name);
|
||||
if(ret == 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ret = run_command(NULL, "%s pull %s",
|
||||
container_cmd, container_image_name);
|
||||
if(ret == 0) {
|
||||
ret = run_command(NULL, "%s tag %s libssh2/openssh_server",
|
||||
container_cmd, container_image_name);
|
||||
if(ret == 0)
|
||||
return ret;
|
||||
}
|
||||
int ret = run_command(NULL, "%s image pull %s%s", container_cmd,
|
||||
/* Requires Apple container 0.7.0+ */
|
||||
strstr(container_cmd, "container") ?
|
||||
"--progress none " : "",
|
||||
container_image_name);
|
||||
if(!ret) {
|
||||
ret = run_command(NULL, "%s image tag %s "
|
||||
"libssh2/openssh_server", container_cmd,
|
||||
container_image_name);
|
||||
if(!ret)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return run_command(NULL,
|
||||
@@ -213,20 +202,18 @@ static int start_openssh_server(char **container_id_out)
|
||||
{
|
||||
if(container_cmd) {
|
||||
const char *container_host_port = openssh_server_port();
|
||||
if(strstr(container_cmd, "container")) {
|
||||
if(!container_host_port) {
|
||||
fprintf(stderr, "OPENSSH_SERVER_PORT must be set\n");
|
||||
return 1;
|
||||
}
|
||||
/* Requires Apple container 0.7.0+ for '--progress none' */
|
||||
return run_command(container_id_out, "%s run --progress none "
|
||||
"--rm -d -p %s:22 libssh2/openssh_server",
|
||||
container_cmd, container_host_port);
|
||||
if(strstr(container_cmd, "container") && !container_host_port) {
|
||||
fprintf(stderr, "OPENSSH_SERVER_PORT must be set\n");
|
||||
return 1;
|
||||
}
|
||||
else if(container_host_port)
|
||||
return run_command(container_id_out, "%s run "
|
||||
if(container_host_port)
|
||||
return run_command(container_id_out, "%s run %s"
|
||||
"--rm -d -p %s:22 libssh2/openssh_server",
|
||||
container_cmd, container_host_port);
|
||||
container_cmd,
|
||||
/* Requires Apple container 0.7.0+ */
|
||||
strstr(container_cmd, "container") ?
|
||||
"--progress none " : "",
|
||||
container_host_port);
|
||||
return run_command(container_id_out, "%s run --rm -d -p 22 "
|
||||
"libssh2/openssh_server", container_cmd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user