Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying multiple container alias #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/TestContainers/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ data ContainerRequest = ContainerRequest
exposedPorts :: [Port],
volumeMounts :: [(Text, Text)],
network :: Maybe (Either Network Text),
networkAlias :: Maybe Text,
networkAlias :: [Text],
links :: [ContainerId],
naming :: NamingStrategy,
rmOnExit :: Bool,
Expand Down Expand Up @@ -303,7 +303,7 @@ containerRequest image =
exposedPorts = [],
volumeMounts = [],
network = Nothing,
networkAlias = Nothing,
networkAlias = [],
links = [],
rmOnExit = False,
readiness = mempty,
Expand Down Expand Up @@ -394,12 +394,13 @@ withNetwork network req =
req {network = Just (Left network)}

-- | Set the network alias for this container. This is equivalent to passing
-- @--network-alias alias@ to @docker run@.
-- @--network-alias alias@ to @docker run@. 'withNetworkAlias' can be used more
-- than once on a 'ContainerRequest'.
--
-- @since 0.5.0.0
withNetworkAlias :: Text -> ContainerRequest -> ContainerRequest
withNetworkAlias alias req =
req {networkAlias = Just alias}
withNetworkAlias alias req@ContainerRequest{networkAlias} =
req {networkAlias = alias : networkAlias }

-- | Sets labels for a container
--
Expand Down Expand Up @@ -557,7 +558,7 @@ run request = do
++ [["--publish", pack (show port) <> "/" <> protocol] | Port {port, protocol} <- exposedPorts]
++ [["--network", networkName] | Just (Right networkName) <- [network]]
++ [["--network", networkId dockerNetwork] | Just (Left dockerNetwork) <- [network]]
++ [["--network-alias", alias] | Just alias <- [networkAlias]]
++ [["--network-alias", alias] | alias <- networkAlias]
++ [["--link", container] | container <- links]
++ [["--volume", src <> ":" <> dest] | (src, dest) <- volumeMounts]
++ [["--rm"] | rmOnExit]
Expand Down