Skip to content

Commit

Permalink
fromExistingNetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbiehl committed Jun 17, 2023
1 parent e9fcea9 commit 9aefe04
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* Introduce `withWorkingDirectory` to set the working directory inside a container (@alexbiehl, https://github.com/testcontainers/testcontainers-hs/pull/37)

* Add `fromExistingNetwork` to allow connecting containers to existing, unmanaged networks (@alexbiehl, https://github.com/testcontainers/testcontainers-hs/pull/41)

## 0.5.0.0 -- 2023-02-20

* BREAKING: Refined lifecycle management. testcontainers is now using testcontainers/ryuk resource reaper to cleanup containers, networks and volumes. Release keys for containers are deprecated. (@alexbiehl, https://github.com/testcontainers/testcontainers-hs/pull/33)
Expand Down
1 change: 1 addition & 0 deletions src/TestContainers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module TestContainers
M.Network,
M.NetworkId,
M.createNetwork,
M.fromExistingNetwork,

-- * Port
M.Port (..),
Expand Down
2 changes: 2 additions & 0 deletions src/TestContainers/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ module TestContainers.Docker
networkId,
networkRequest,
createNetwork,
fromExistingNetwork,
withIpv6,
withDriver,

Expand Down Expand Up @@ -227,6 +228,7 @@ import TestContainers.Docker.Network
NetworkId,
NetworkRequest,
createNetwork,
fromExistingNetwork,
networkId,
networkRequest,
withDriver,
Expand Down
10 changes: 10 additions & 0 deletions src/TestContainers/Docker/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module TestContainers.Docker.Network
networkId,

-- * Creating networks
fromExistingNetwork,
createNetwork,
NetworkRequest,
networkRequest,
Expand Down Expand Up @@ -74,6 +75,15 @@ withDriver :: Text -> NetworkRequest -> NetworkRequest
withDriver driver request =
request {driver = Just driver}

-- | Creates a 'Network' from an existing 'NetworkId'. Note that the 'Network' is
-- not managed by the 'TestContainer' monad and as such is not being cleaned up
-- afterwards.
--
-- @since x.x.x
fromExistingNetwork :: NetworkId -> TestContainer Network
fromExistingNetwork id =
pure Network {id}

-- | Creates a new 'Network' from a 'NetworkRequest'.
--
-- @since 0.5.0.0
Expand Down

0 comments on commit 9aefe04

Please sign in to comment.