Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah committed Oct 13, 2023
1 parent a87eda1 commit 32dd73a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/container.ex
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ defmodule TestcontainersElixir.Container do
end

def run(%__MODULE__{} = container_config, options \\ []) do
connection = Keyword.get_lazy(options, :connection, &Connection.get_connection/0)
connection = Connection.get_connection()
on_exit = Keyword.get(options, :on_exit, fn _, _ -> :ok end)
waiting_strategy = Keyword.get(options, :waiting_strategy, nil)
reap = Keyword.get(options, :reap, true)
Expand Down
9 changes: 3 additions & 6 deletions lib/reaper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
defmodule TestcontainersElixir.Reaper do
use GenServer

alias TestcontainersElixir.Connection
alias TestcontainersElixir.Container

@ryuk_image "testcontainers/ryuk:0.5.1"
Expand All @@ -18,9 +17,7 @@ defmodule TestcontainersElixir.Reaper do

@impl true
def init(_) do
connection = Connection.get_connection()

with {:ok, container} <- create_ryuk_container(connection),
with {:ok, container} <- create_ryuk_container(),
{:ok, socket} <- create_ryuk_socket(container) do
{:ok, socket}
else
Expand Down Expand Up @@ -54,13 +51,13 @@ defmodule TestcontainersElixir.Reaper do
end
end

defp create_ryuk_container(connection) do
defp create_ryuk_container do
%Container{image: @ryuk_image}
|> Container.with_exposed_port(@ryuk_port)
|> Container.with_environment("RYUK_PORT", "#{@ryuk_port}")
|> Container.with_environment("RYUK_CONNECTION_TIMEOUT", "120s")
|> Container.with_bind_mount("/var/run/docker.sock", "/var/run/docker.sock", "rw")
|> Container.run(connection: connection, reap: false)
|> Container.run(reap: false)
end

defp create_ryuk_socket(%Container{} = container) do
Expand Down

0 comments on commit 32dd73a

Please sign in to comment.