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"
|
||||
|
||||
defp container_runtime_binary do
|
||||
System.find_executable("podman") || System.find_executable("docker")
|
||||
end
|
||||
|
||||
def start() do
|
||||
case System.find_executable("podman") do
|
||||
case container_runtime_binary() do
|
||||
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
|
||||
podman ->
|
||||
binary ->
|
||||
Logger.info("Starting LDAP environment.")
|
||||
container = container_name()
|
||||
port = Port.open(
|
||||
{:spawn_executable, podman},
|
||||
{:spawn_executable, binary},
|
||||
[:binary, args: [
|
||||
"run", "--rm", "--name", container, "-p", "3089:389", @image
|
||||
]])
|
||||
|
@ -34,8 +38,8 @@ defmodule RecycledCloud.LDAPTestEnvironment do
|
|||
def stop(name) do
|
||||
Logger.info "Terminating LDAP Test Environment."
|
||||
|
||||
podman = System.find_executable("podman")
|
||||
System.cmd(podman, ["stop", name])
|
||||
binary = container_runtime_binary()
|
||||
System.cmd(binary, ["stop", name])
|
||||
end
|
||||
|
||||
defp container_name, do: "ldap-playground-#{System.unique_integer()}"
|
||||
|
|
Loading…
Reference in a new issue