LDAP Test Environment: fallback to docker if podman is not available
This commit is contained in:
parent
8680152e19
commit
539e1146d1
1 changed files with 10 additions and 6 deletions
|
@ -4,17 +4,21 @@ defmodule RecycledCloud.LDAPTestEnvironment do
|
||||||
|
|
||||||
@image "code.ungleich.ch:5050/fnux/e-durable-oci-images/openldap-playground:latest"
|
@image "code.ungleich.ch:5050/fnux/e-durable-oci-images/openldap-playground:latest"
|
||||||
|
|
||||||
|
defp container_runtime_binary do
|
||||||
|
System.find_executable("podman") || System.find_executable("docker")
|
||||||
|
end
|
||||||
|
|
||||||
def start() do
|
def start() do
|
||||||
case System.find_executable("podman") do
|
case container_runtime_binary() do
|
||||||
nil ->
|
nil ->
|
||||||
Logger.error("Could not find podman executable (required for LDAP environment). Exiting.")
|
Logger.error("Could not find a container runtime (required for LDAP environment). Exiting.")
|
||||||
|
|
||||||
:error
|
:error
|
||||||
podman ->
|
binary ->
|
||||||
Logger.info("Starting LDAP environment.")
|
Logger.info("Starting LDAP environment.")
|
||||||
container = container_name()
|
container = container_name()
|
||||||
port = Port.open(
|
port = Port.open(
|
||||||
{:spawn_executable, podman},
|
{:spawn_executable, binary},
|
||||||
[:binary, args: [
|
[:binary, args: [
|
||||||
"run", "--rm", "--name", container, "-p", "3089:389", @image
|
"run", "--rm", "--name", container, "-p", "3089:389", @image
|
||||||
]])
|
]])
|
||||||
|
@ -34,8 +38,8 @@ defmodule RecycledCloud.LDAPTestEnvironment do
|
||||||
def stop(name) do
|
def stop(name) do
|
||||||
Logger.info "Terminating LDAP Test Environment."
|
Logger.info "Terminating LDAP Test Environment."
|
||||||
|
|
||||||
podman = System.find_executable("podman")
|
binary = container_runtime_binary()
|
||||||
System.cmd(podman, ["stop", name])
|
System.cmd(binary, ["stop", name])
|
||||||
end
|
end
|
||||||
|
|
||||||
defp container_name, do: "ldap-playground-#{System.unique_integer()}"
|
defp container_name, do: "ldap-playground-#{System.unique_integer()}"
|
||||||
|
|
Loading…
Reference in a new issue