on master help sign in
Makes addBind function consistent with others
commit18482fcbb7fe1379a512c2e620f47c6a44048bed authorDeni Bertovic <deni@denibertovic.com> dateThu 1 Sep 2016, 22:11 (10 years ago) parent4160f26
2 files changed+8−4
examples/Example.hs+2−1 src/Docker/Client/Types.hs+6−3
examples/Example.hs+2−1
@@ -21,7 +21,8 @@ stopNginxContainer cid = runDockerT (defaultClientOpts, defaultHttpHandler) $ do
2121runPostgresContainer :: IO ContainerID
2222runPostgresContainer = runDockerT (defaultClientOpts, defaultHttpHandler) $ do
2323 let pb = PortBinding 5432 TCP [HostPort "0.0.0.0" 5432]
24− let myCreateOpts = addBinds [Bind "/tmp" "/tmp" Nothing] $ addPortBinding pb $ defaultCreateOpts "postgres:9.5"
24+ let b = Bind "/tmp" "/tmp" Nothing
25+ let myCreateOpts = addBind b $ addPortBinding pb $ defaultCreateOpts "postgres:9.5"
2526 cid <- createContainer myCreateOpts Nothing
2627 case cid of
2728 Left err -> error $ show err
src/Docker/Client/Types.hs+6−3
@@ -78,7 +78,7 @@ module Docker.Client.Types (
7878 , DeviceWeight(..)
7979 , DeviceRate(..)
8080 , addPortBinding
81− , addBinds
81+ , addBind
8282 ) where
8383
8484import Data.Aeson (FromJSON, ToJSON, genericParseJSON,
@@ -926,9 +926,12 @@ portAndType2Text :: Port -> PortType -> Text
926926portAndType2Text p t = (T.pack $ show p) <> "/" <> (T.pack $ show t)
927927
928928
929−addBinds :: [Bind] -> CreateOpts -> CreateOpts
930−addBinds bs c = c{hostConfig=hc{binds=bs}}
929+-- | A helper function to more easily add a bind mount to existing
930+-- "CreateOpts" records.
931+addBind :: Bind -> CreateOpts -> CreateOpts
932+addBind b c = c{hostConfig=hc{binds=obs <> [b]}}
931933 where hc = hostConfig c
934+ obs = binds $ hostConfig c
932935
933936-- | A convenience function that adds PortBindings to and exiting
934937-- "CreateOpts" record. Useful with 'defaultCreateOpts'