mirror of
https://github.com/ilyakooo0/docker-hs.git
synced 2024-09-11 10:35:29 +03:00
Stop using Maybe for NetworkingConfig in CreateOpts; add alias for EndpointName
This commit is contained in:
parent
1b7f0704f8
commit
c3c22fe05c
@ -624,9 +624,12 @@ instance ToJSON EndpointConfig where
|
||||
[ "Aliases" .= aliases
|
||||
]
|
||||
|
||||
-- | Alias for endpoint name
|
||||
type EndpointName = Text
|
||||
|
||||
-- | Data type for the NetworkingConfig section of the container settings
|
||||
newtype NetworkingConfig = NetworkingConfig
|
||||
{ endpointsConfig :: HM.HashMap Text EndpointConfig
|
||||
{ endpointsConfig :: HM.HashMap EndpointName EndpointConfig
|
||||
} deriving (Eq, Show)
|
||||
|
||||
instance ToJSON NetworkingConfig where
|
||||
@ -636,9 +639,9 @@ instance ToJSON NetworkingConfig where
|
||||
|
||||
-- | Options used for creating a Container.
|
||||
data CreateOpts = CreateOpts {
|
||||
containerConfig :: ContainerConfig
|
||||
, hostConfig :: HostConfig
|
||||
, networkingConfig :: Maybe NetworkingConfig
|
||||
containerConfig :: ContainerConfig
|
||||
, hostConfig :: HostConfig
|
||||
, networkingConfig :: NetworkingConfig
|
||||
} deriving (Eq, Show)
|
||||
|
||||
instance ToJSON CreateOpts where
|
||||
@ -648,9 +651,7 @@ instance ToJSON CreateOpts where
|
||||
case ccJSON of
|
||||
JSON.Object (o :: HM.HashMap T.Text JSON.Value) -> do
|
||||
let o1 = HM.insert "HostConfig" hcJSON o
|
||||
let o2 = case nc of
|
||||
Nothing -> o1
|
||||
Just _ -> HM.insert "NetworkingConfig" (toJSON nc) o1
|
||||
let o2 = HM.insert "NetworkingConfig" (toJSON nc) o1
|
||||
JSON.Object o2
|
||||
_ -> error "ContainerConfig is not an object." -- This should never happen.
|
||||
|
||||
@ -736,7 +737,7 @@ defaultCreateOpts :: T.Text -> CreateOpts
|
||||
defaultCreateOpts imageName = CreateOpts
|
||||
{ containerConfig = defaultContainerConfig imageName
|
||||
, hostConfig = defaultHostConfig
|
||||
, networkingConfig = Nothing
|
||||
, networkingConfig = NetworkingConfig HM.empty
|
||||
}
|
||||
|
||||
-- | Override the key sequence for detaching a container.
|
||||
|
@ -94,7 +94,7 @@ testRunAndReadLog =
|
||||
runDocker $
|
||||
do let containerConfig = (defaultContainerConfig (testImageName <> ":latest")) {env = [EnvVar "TEST" "123"]}
|
||||
networkingConfig = NetworkingConfig $ HM.fromList [("test-network", EndpointConfig ["cellar-door"])]
|
||||
containerId <- createContainer (CreateOpts containerConfig defaultHostConfig (Just networkingConfig)) Nothing
|
||||
containerId <- createContainer (CreateOpts containerConfig defaultHostConfig networkingConfig) Nothing
|
||||
c <- fromRight containerId
|
||||
status1 <- startContainer defaultStartOpts c
|
||||
_ <- inspectContainer c >>= fromRight
|
||||
|
Loading…
Reference in New Issue
Block a user