@@ -11,9 +11,6 @@ module Docker.Client.Types (
12 , fromImageID
12 , fromImageID
13 , toImageID
13 , toImageID
17 , Timeout(..)
14 , Timeout(..)
18 , StatusCode(..)
15 , StatusCode(..)
19 , Signal(..)
16 , Signal(..)
@@ -40,16 +37,12 @@ module Docker.Client.Types (
40 , DetachKeys(..)
37 , DetachKeys(..)
41 , StartOpts(..)
38 , StartOpts(..)
42 , defaultStartOpts
39 , defaultStartOpts
43− , ContainerDeleteOpts(..)
40+ , DeleteOpts(..)
44− , defaultContainerDeleteOpts
41+ , defaultDeleteOpts
45− , ImageDeleteOpts(..)
46− , defaultImageDeleteOpts
47 , Timestamp
42 , Timestamp
48 , TailLogOpt(..)
43 , TailLogOpt(..)
49 , LogOpts(..)
44 , LogOpts(..)
50 , defaultLogOpts
45 , defaultLogOpts
51− , CreateNetworkOpts(..)
52− , defaultCreateNetworkOpts
53 , VolumePermission(..)
46 , VolumePermission(..)
54 , Bind(..)
47 , Bind(..)
55 , Volume(..)
48 , Volume(..)
@@ -132,13 +125,10 @@ data Endpoint =
132 | UnpauseContainerEndpoint ContainerID
125 | UnpauseContainerEndpoint ContainerID
133 | ContainerLogsEndpoint LogOpts Bool ContainerID -- ^ Second argument (Bool) is whether to follow which is currently hardcoded to False.
126 | ContainerLogsEndpoint LogOpts Bool ContainerID -- ^ Second argument (Bool) is whether to follow which is currently hardcoded to False.
134 -- See note in 'Docker.Client.Api.getContainerLogs' for explanation why.
127 -- See note in 'Docker.Client.Api.getContainerLogs' for explanation why.
135− | DeleteContainerEndpoint ContainerDeleteOpts ContainerID
128+ | DeleteContainerEndpoint DeleteOpts ContainerID
136 | InspectContainerEndpoint ContainerID
129 | InspectContainerEndpoint ContainerID
137 | BuildImageEndpoint BuildOpts FilePath
130 | BuildImageEndpoint BuildOpts FilePath
138 | CreateImageEndpoint T.Text Tag (Maybe T.Text) -- ^ Either pull an image from docker hub or imports an image from a tarball (or URL)
131 | CreateImageEndpoint T.Text Tag (Maybe T.Text) -- ^ Either pull an image from docker hub or imports an image from a tarball (or URL)
139− | DeleteImageEndpoint ImageDeleteOpts ImageID
140− | CreateNetworkEndpoint CreateNetworkOpts
141− | RemoveNetworkEndpoint NetworkID
142 deriving (Eq, Show)
132 deriving (Eq, Show)
144-- | We should newtype this
134-- | We should newtype this
@@ -634,12 +624,9 @@ instance ToJSON EndpointConfig where
634 [ "Aliases" .= aliases
624 [ "Aliases" .= aliases
637−-- | Alias for endpoint name
638−type EndpointName = Text
640-- | Data type for the NetworkingConfig section of the container settings
627-- | Data type for the NetworkingConfig section of the container settings
641newtype NetworkingConfig = NetworkingConfig
628newtype NetworkingConfig = NetworkingConfig
642− { endpointsConfig :: HM.HashMap EndpointName EndpointConfig
629+ { endpointsConfig :: HM.HashMap Text EndpointConfig
643 } deriving (Eq, Show)
630 } deriving (Eq, Show)
645instance ToJSON NetworkingConfig where
632instance ToJSON NetworkingConfig where
@@ -649,9 +636,9 @@ instance ToJSON NetworkingConfig where
650-- | Options used for creating a Container.
637-- | Options used for creating a Container.
651data CreateOpts = CreateOpts {
638data CreateOpts = CreateOpts {
652− containerConfig :: ContainerConfig
639+ containerConfig :: ContainerConfig
653− , hostConfig :: HostConfig
640+ , hostConfig :: HostConfig
654− , networkingConfig :: NetworkingConfig
641+ , networkingConfig :: Maybe NetworkingConfig
655 } deriving (Eq, Show)
642 } deriving (Eq, Show)
657instance ToJSON CreateOpts where
644instance ToJSON CreateOpts where
@@ -661,7 +648,9 @@ instance ToJSON CreateOpts where
661 case ccJSON of
648 case ccJSON of
662 JSON.Object (o :: HM.HashMap T.Text JSON.Value) -> do
649 JSON.Object (o :: HM.HashMap T.Text JSON.Value) -> do
663 let o1 = HM.insert "HostConfig" hcJSON o
650 let o1 = HM.insert "HostConfig" hcJSON o
664− let o2 = HM.insert "NetworkingConfig" (toJSON nc) o1
653+ Just _ -> HM.insert "NetworkingConfig" (toJSON nc) o1
665 JSON.Object o2
654 JSON.Object o2
666 _ -> error "ContainerConfig is not an object." -- This should never happen.
655 _ -> error "ContainerConfig is not an object." -- This should never happen.
@@ -747,7 +736,7 @@ defaultCreateOpts :: T.Text -> CreateOpts
747defaultCreateOpts imageName = CreateOpts
736defaultCreateOpts imageName = CreateOpts
748 { containerConfig = defaultContainerConfig imageName
737 { containerConfig = defaultContainerConfig imageName
749 , hostConfig = defaultHostConfig
738 , hostConfig = defaultHostConfig
750− , networkingConfig = NetworkingConfig HM.empty
739+ , networkingConfig = Nothing
753-- | Override the key sequence for detaching a container.
742-- | Override the key sequence for detaching a container.
@@ -762,7 +751,7 @@ defaultStartOpts :: StartOpts
762defaultStartOpts = StartOpts { detachKeys = DefaultDetachKey }
751defaultStartOpts = StartOpts { detachKeys = DefaultDetachKey }
764-- | Options for deleting a container.
753-- | Options for deleting a container.
765−data ContainerDeleteOpts = ContainerDeleteOpts {
754+data DeleteOpts = DeleteOpts {
766 deleteVolumes :: Bool -- ^ Automatically cleanup volumes that the container created as well.
755 deleteVolumes :: Bool -- ^ Automatically cleanup volumes that the container created as well.
767 , force :: Bool -- ^ If the container is still running force deletion anyway.
756 , force :: Bool -- ^ If the container is still running force deletion anyway.
768 } deriving (Eq, Show)
757 } deriving (Eq, Show)
@@ -792,15 +781,8 @@ defaultBuildOpts nameTag = BuildOpts { buildImageName = nameTag
792-- | Default options for deleting a container. Most of the time we DON'T
781-- | Default options for deleting a container. Most of the time we DON'T
793-- want to delete the container's volumes or force delete it if it's
782-- want to delete the container's volumes or force delete it if it's
794-- running.
783-- running.
795−defaultContainerDeleteOpts :: ContainerDeleteOpts
784+defaultDeleteOpts :: DeleteOpts
796−defaultContainerDeleteOpts = ContainerDeleteOpts { deleteVolumes = False, force = False }
785+defaultDeleteOpts = DeleteOpts { deleteVolumes = False, force = False }
798−-- | Image delete opts
799−data ImageDeleteOpts = ImageDeleteOpts deriving (Eq, Show)
801−-- | Sane image deletion defaults
802−defaultImageDeleteOpts :: ImageDeleteOpts
803−defaultImageDeleteOpts = ImageDeleteOpts
805-- | Timestamp alias.
787-- | Timestamp alias.
806type Timestamp = Integer
788type Timestamp = Integer
@@ -828,36 +810,6 @@ defaultLogOpts = LogOpts { stdout = True
828 , tail = All
810 , tail = All
831−-- | Options for creating a network
832−data CreateNetworkOpts = CreateNetworkOpts
833− { createNetworkName :: Text -- ^ The network's name
834− , createNetworkCheckDuplicate :: Bool -- ^ Check for networks with duplicate names.
835− , createNetworkDriver :: Text -- ^ Name of the network driver plugin to use.
836− , createNetworkInternal :: Bool -- ^ Restrict external access to the network.
837− , createNetworkEnableIPv6 :: Bool -- ^ Enable IPv6 on the network.
838− } deriving (Eq, Show)
840−-- | Sensible defalut for create network options
841−defaultCreateNetworkOpts :: Text -> CreateNetworkOpts
842−defaultCreateNetworkOpts name =
844− { createNetworkName = name
845− , createNetworkCheckDuplicate = False
846− , createNetworkDriver = "bridge"
847− , createNetworkInternal = True
848− , createNetworkEnableIPv6 = False
851−instance ToJSON CreateNetworkOpts where
854− [ "Name" .= createNetworkName opts
855− , "CheckDuplicate" .= createNetworkCheckDuplicate opts
856− , "Driver" .= createNetworkDriver opts
857− , "Internal" .= createNetworkInternal opts
858− , "EnableIPv6" .= createNetworkEnableIPv6 opts
861-- TOOD: Add support for SELinux Volume labels (eg. "ro,z" or "ro/Z")
813-- TOOD: Add support for SELinux Volume labels (eg. "ro,z" or "ro/Z")
862-- | Set permissions on volumes that you mount in the container.
814-- | Set permissions on volumes that you mount in the container.
863data VolumePermission = ReadWrite | ReadOnly deriving (Eq, Show, Generic)
815data VolumePermission = ReadWrite | ReadOnly deriving (Eq, Show, Generic)
@@ -1033,26 +985,6 @@ instance ToJSON NetworkMode where
1033 toJSON NetworkDisabled = JSON.String "none"
985 toJSON NetworkDisabled = JSON.String "none"
1034 toJSON (NetworkNamed n) = JSON.String n
986 toJSON (NetworkNamed n) = JSON.String n
1036−newtype NetworkID = NetworkID Text
1037− deriving (Eq, Show)
1039−-- | Used for extracting the id of the container from the newtype
1040−fromNetworkID :: NetworkID -> Text
1041−fromNetworkID (NetworkID t) = t
1043−-- | Used for parsing a Text value into a NetworkID.
1044−toNetworkID :: Text -> Maybe NetworkID
1045−toNetworkID t = Just $ NetworkID t
1047−instance FromJSON NetworkID where
1048− parseJSON (JSON.Object o) = do
1050− return $ NetworkID nid
1051− parseJSON _ = fail "NetworkID is not an object."
1053−instance ToJSON NetworkID where
1054− toJSON (NetworkID nid) = object ["Id" .= nid]
1056data PortType = TCP | UDP deriving (Eq, Generic, Read, Ord)
988data PortType = TCP | UDP deriving (Eq, Generic, Read, Ord)
1058instance Show PortType where
990instance Show PortType where
@@ -1564,11 +1496,7 @@ instance FromJSON ContainerConfig where
1564 macAddress labels stopSignal
1496 macAddress labels stopSignal
1565 parseJSON _ = fail "NetworkSettings is not an object."
1497 parseJSON _ = fail "NetworkSettings is not an object."
1567−#if MIN_VERSION_base(4,13,0)
1568−parseIntegerText :: (MonadFail m) => Text -> m Integer
1570parseIntegerText :: (Monad m) => Text -> m Integer
1499parseIntegerText :: (Monad m) => Text -> m Integer
1572parseIntegerText t = case readMaybe $ T.unpack t of
1500parseIntegerText t = case readMaybe $ T.unpack t of
1573 Nothing ->
1501 Nothing ->
1574 fail "Could not parse Integer"
1502 fail "Could not parse Integer"