Skip to content

Commit 8ced2f3

Browse files
authored
send user agent to docker engine api + rename protocol method (#93)
* send user agent to docker engine api * fix constant * rename method
1 parent 81718ba commit 8ced2f3

18 files changed

+89
-56
lines changed

lib/container.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,12 @@ defmodule Testcontainers.Container do
171171
config
172172
end
173173

174+
@doc """
175+
Do stuff after container has started.
176+
"""
174177
@impl true
175-
@spec is_starting(%Testcontainers.Container{}, %Testcontainers.Container{}, %Tesla.Env{}) ::
178+
@spec after_start(%Testcontainers.Container{}, %Testcontainers.Container{}, %Tesla.Env{}) ::
176179
:ok
177-
def is_starting(_config, _container, _conn), do: :ok
180+
def after_start(_config, _container, _conn), do: :ok
178181
end
179182
end

lib/container/cassandra_container.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ defmodule Testcontainers.CassandraContainer do
8282
end
8383

8484
@impl true
85-
@spec is_starting(%CassandraContainer{}, %Container{}, %Tesla.Env{}) :: :ok
86-
def is_starting(_config, _container, _conn), do: :ok
85+
@spec after_start(%CassandraContainer{}, %Container{}, %Tesla.Env{}) :: :ok
86+
def after_start(_config, _container, _conn), do: :ok
8787
end
8888
end

lib/container/ceph_container.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ defmodule Testcontainers.CephContainer do
232232
end
233233

234234
@impl true
235-
@spec is_starting(%CephContainer{}, %Container{}, %Tesla.Env{}) :: :ok
236-
def is_starting(_config, _container, _conn), do: :ok
235+
@spec after_start(%CephContainer{}, %Container{}, %Tesla.Env{}) :: :ok
236+
def after_start(_config, _container, _conn), do: :ok
237237
end
238238
end
239239

lib/container/emqx_container.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ defmodule Testcontainers.EmqxContainer do
144144
]
145145

146146
@impl true
147-
# TODO Implement the `is_starting/3` function for the `ContainerBuilder` protocol.
148-
def is_starting(_config, _container, _conn), do: :ok
147+
# TODO Implement the `after_start/3` function for the `ContainerBuilder` protocol.
148+
def after_start(_config, _container, _conn), do: :ok
149149
end
150150
end

lib/container/kafka_container.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,13 @@ defmodule Testcontainers.KafkaContainer do
168168
end
169169

170170
@doc """
171-
Checks if the container is starting.
172-
If yes, that means that we know both the host and the port of the container and we can
171+
Do stuff after container has started.
172+
We now know both the host and the port of the container and we can
173173
assign them to the config.
174174
"""
175175
@impl true
176-
@spec is_starting(%KafkaContainer{}, %Testcontainers.Container{}, %Tesla.Env{}) :: :ok
177-
def is_starting(config = %{start_file_path: start_file_path}, container, conn) do
176+
@spec after_start(%KafkaContainer{}, %Testcontainers.Container{}, %Tesla.Env{}) :: :ok
177+
def after_start(config = %{start_file_path: start_file_path}, container, conn) do
178178
with script <- build_startup_script(container, config),
179179
{:ok, _} <-
180180
Docker.Api.put_file(container.container_id, conn, "/", start_file_path, script) do

lib/container/minio_container.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ defmodule Testcontainers.MinioContainer do
7676
end
7777

7878
@impl true
79-
@spec is_starting(%MinioContainer{}, %Container{}, %Tesla.Env{}) :: :ok
80-
def is_starting(_config, _container, _conn), do: :ok
79+
@spec after_start(%MinioContainer{}, %Container{}, %Tesla.Env{}) :: :ok
80+
def after_start(_config, _container, _conn), do: :ok
8181
end
8282
end

lib/container/mysql_container.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ defmodule Testcontainers.MySqlContainer do
207207
end
208208

209209
@impl true
210-
@spec is_starting(%MySqlContainer{}, %Container{}, %Tesla.Env{}) :: :ok
211-
def is_starting(_config, _container, _conn), do: :ok
210+
@spec after_start(%MySqlContainer{}, %Container{}, %Tesla.Env{}) :: :ok
211+
def after_start(_config, _container, _conn), do: :ok
212212
end
213213

214214
@doc false

lib/container/postgres_container.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ defmodule Testcontainers.PostgresContainer do
213213
end
214214

215215
@impl true
216-
@spec is_starting(%PostgresContainer{}, %Container{}, %Tesla.Env{}) :: :ok
217-
def is_starting(_config, _container, _conn), do: :ok
216+
@spec after_start(%PostgresContainer{}, %Container{}, %Tesla.Env{}) :: :ok
217+
def after_start(_config, _container, _conn), do: :ok
218218
end
219219

220220
@doc false

lib/container/protocols/container_builder.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ defprotocol Testcontainers.ContainerBuilder do
55
@spec build(t()) :: %Testcontainers.Container{}
66
def build(builder)
77

8-
@spec is_starting(t(), %Testcontainers.Container{}, %Tesla.Env{}) :: :ok
9-
def is_starting(builder, container, connection)
8+
@doc """
9+
Do stuff after container has started.
10+
"""
11+
@spec after_start(t(), %Testcontainers.Container{}, %Tesla.Env{}) :: :ok
12+
def after_start(builder, container, connection)
1013
end

lib/container/rabbitmq_container.ex

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ defmodule Testcontainers.RabbitMQContainer do
4545
Overrides the default image use for the RabbitMQ container.
4646
4747
## Examples
48-
48+
4949
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_image("rabbitmq:xyz")
5050
iex> config.image
5151
"rabbitmq:xyz"
@@ -58,7 +58,7 @@ defmodule Testcontainers.RabbitMQContainer do
5858
Overrides the default port used for the RabbitMQ container.
5959
6060
## Examples
61-
61+
6262
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_port(1111)
6363
iex> config.port
6464
1111
@@ -73,7 +73,7 @@ defmodule Testcontainers.RabbitMQContainer do
7373
Note: this timeout will be used for each individual wait strategy.
7474
7575
## Examples
76-
76+
7777
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_wait_timeout(60000)
7878
iex> config.wait_timeout
7979
60000
@@ -86,7 +86,7 @@ defmodule Testcontainers.RabbitMQContainer do
8686
Overrides the default user used for the RabbitMQ container.
8787
8888
## Examples
89-
89+
9090
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_username("rabbitmq")
9191
iex> config.username
9292
"rabbitmq"
@@ -99,7 +99,7 @@ defmodule Testcontainers.RabbitMQContainer do
9999
Overrides the default password used for the RabbitMQ container.
100100
101101
## Examples
102-
102+
103103
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_password("rabbitmq")
104104
iex> config.password
105105
"rabbitmq"
@@ -112,7 +112,7 @@ defmodule Testcontainers.RabbitMQContainer do
112112
Overrides the default virtual host used for the RabbitMQ container.
113113
114114
## Examples
115-
115+
116116
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_virtual_host("/")
117117
iex> config.password
118118
"/"
@@ -125,7 +125,7 @@ defmodule Testcontainers.RabbitMQContainer do
125125
Overrides the default command used for the RabbitMQ container.
126126
127127
## Examples
128-
128+
129129
iex> config = RabbitMQContainer.new() |> RabbitMQContainer.with_cmd(["sh", "-c", "rabbitmq-server"])
130130
iex> config.cmd
131131
["sh", "-c", "rabbitmq-server"]
@@ -172,9 +172,9 @@ defmodule Testcontainers.RabbitMQContainer do
172172
## Examples
173173
174174
iex> RabbitMQContainer.connection_url(container)
175-
"amqp://guest:guest@localhost:32768"
175+
"amqp://guest:guest@localhost:32768"
176176
iex> RabbitMQContainer.connection_url(container_with_vhost)
177-
"amqp://guest:guest@localhost:32768/vhost"
177+
"amqp://guest:guest@localhost:32768/vhost"
178178
"""
179179
def connection_url(%Container{} = container) do
180180
"amqp://#{container.environment[:RABBITMQ_DEFAULT_USER]}:#{container.environment[:RABBITMQ_DEFAULT_PASS]}@#{Testcontainers.get_host()}:#{port(container)}#{virtual_host_segment(container)}"
@@ -264,7 +264,7 @@ defmodule Testcontainers.RabbitMQContainer do
264264
end
265265

266266
@impl true
267-
@spec is_starting(%RabbitMQContainer{}, %Container{}, %Tesla.Env{}) :: :ok
268-
def is_starting(_config, _container, _conn), do: :ok
267+
@spec after_start(%RabbitMQContainer{}, %Container{}, %Tesla.Env{}) :: :ok
268+
def after_start(_config, _container, _conn), do: :ok
269269
end
270270
end

0 commit comments

Comments
 (0)