on master help sign in
Stop using Maybe for NetworkingConfig in CreateOpts; add alias for EndpointName
commitc3c22fe05c67e851ca407302a314b2575c5c4260 authorDaQuirm <leo.daquirm@gmail.com> dateSat 14 Apr 2018, 23:09 (9 years ago) parent1b7f070
2 files changed+10−9
src/Docker/Client/Types.hs+9−8 tests/tests.hs+1−1
src/Docker/Client/Types.hs+9−8
@@ -624,9 +624,12 @@ instance ToJSON EndpointConfig where
624624 [ "Aliases" .= aliases
625625 ]
626626
627+-- | Alias for endpoint name
628+type EndpointName = Text
629+
627630-- | Data type for the NetworkingConfig section of the container settings
628631newtype NetworkingConfig = NetworkingConfig
629− { endpointsConfig :: HM.HashMap Text EndpointConfig
632+ { endpointsConfig :: HM.HashMap EndpointName EndpointConfig
630633 } deriving (Eq, Show)
631634
632635instance ToJSON NetworkingConfig where
@@ -636,9 +639,9 @@ instance ToJSON NetworkingConfig where
636639
637640-- | Options used for creating a Container.
638641data CreateOpts = CreateOpts {
639− containerConfig :: ContainerConfig
640− , hostConfig :: HostConfig
641− , networkingConfig :: Maybe NetworkingConfig
642+ containerConfig :: ContainerConfig
643+ , hostConfig :: HostConfig
644+ , networkingConfig :: NetworkingConfig
642645 } deriving (Eq, Show)
643646
644647instance ToJSON CreateOpts where
@@ -648,9 +651,7 @@ instance ToJSON CreateOpts where
648651 case ccJSON of
649652 JSON.Object (o :: HM.HashMap T.Text JSON.Value) -> do
650653 let o1 = HM.insert "HostConfig" hcJSON o
651− let o2 = case nc of
652− Nothing -> o1
653− Just _ -> HM.insert "NetworkingConfig" (toJSON nc) o1
654+ let o2 = HM.insert "NetworkingConfig" (toJSON nc) o1
654655 JSON.Object o2
655656 _ -> error "ContainerConfig is not an object." -- This should never happen.
656657
@@ -736,7 +737,7 @@ defaultCreateOpts :: T.Text -> CreateOpts
736737defaultCreateOpts imageName = CreateOpts
737738 { containerConfig = defaultContainerConfig imageName
738739 , hostConfig = defaultHostConfig
739− , networkingConfig = Nothing
740+ , networkingConfig = NetworkingConfig HM.empty
740741 }
741742
742743-- | Override the key sequence for detaching a container.
tests/tests.hs+1−1
@@ -94,7 +94,7 @@ testRunAndReadLog =
9494 runDocker $
9595 do let containerConfig = (defaultContainerConfig (testImageName <> ":latest")) {env = [EnvVar "TEST" "123"]}
9696 networkingConfig = NetworkingConfig $ HM.fromList [("test-network", EndpointConfig ["cellar-door"])]
97− containerId <- createContainer (CreateOpts containerConfig defaultHostConfig (Just networkingConfig)) Nothing
97+ containerId <- createContainer (CreateOpts containerConfig defaultHostConfig networkingConfig) Nothing
9898 c <- fromRight containerId
9999 status1 <- startContainer defaultStartOpts c
100100 _ <- inspectContainer c >>= fromRight