on master help sign in
Merge branch 'dev' of https://github.com/jprider63/docker-hs into dev
70d77aaDeni Bertovic
src/Docker/Client/Types.hs+175−66
@@ -49,7 +49,7 @@ module Docker.Client.Types (
49 , LogDriverConfig(..)
49 , LogDriverConfig(..)
50 , NetworkMode(..)
50 , NetworkMode(..)
51 , PortType(..)
51 , PortType(..)
52− , NetworkInterface(..)
52+-- , NetworkInterface(..)
53 , Networks(..)
53 , Networks(..)
54 , NetworkSettings(..)
54 , NetworkSettings(..)
55 , NetworkOptions(..)
55 , NetworkOptions(..)
@@ -73,6 +73,8 @@ module Docker.Client.Types (
73 , ContainerConfig(..)
73 , ContainerConfig(..)
74 , defaultContainerConfig
74 , defaultContainerConfig
75 , ExposedPorts(..)
75 , ExposedPorts(..)
76+ , DeviceWeight(..)
77+ , DeviceRate(..)
76 ) where
78 ) where
77
79
78import Data.Aeson (FromJSON, ToJSON, genericParseJSON,
80import Data.Aeson (FromJSON, ToJSON, genericParseJSON,
@@ -282,11 +284,8 @@ instance FromJSON DockerVersion where
282 parseJSON = genericParseJSON defaultOptions {
284 parseJSON = genericParseJSON defaultOptions {
283 fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
285 fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
284
286
285−-- instance ToJSON ContainerDetails where
286−-- toJSON = error "TODO"
287−
288instance FromJSON ContainerDetails where
287instance FromJSON ContainerDetails where
289− parseJSON (JSON.Object o) = do
288+ parseJSON v@(JSON.Object o) = do
290 appArmor <- o .: "AppArmorProfile"
289 appArmor <- o .: "AppArmorProfile"
291 args <- o .: "Args"
290 args <- o .: "Args"
292 config <- o .: "Config"
291 config <- o .: "Config"
@@ -296,7 +295,7 @@ instance FromJSON ContainerDetails where
296 hostnamePath <- o .: "HostnamePath"
295 hostnamePath <- o .: "HostnamePath"
297 hostsPath <- o .: "HostsPath"
296 hostsPath <- o .: "HostsPath"
298 logPath <- o .: "LogPath"
297 logPath <- o .: "LogPath"
299− id <- o .: "Id"
298+ id <- parseJSON v
300 image <- o .: "Image"
299 image <- o .: "Image"
301 mountLabel <- o .: "MountLabel"
300 mountLabel <- o .: "MountLabel"
302 name <- o .: "Name"
301 name <- o .: "Name"
@@ -401,7 +400,7 @@ data NetworkSettings = NetworkSettings {
401 , networkSettingsHairpinMode :: Bool
400 , networkSettingsHairpinMode :: Bool
402 , networkSettingsLinkLocalIPv6Address :: Text
401 , networkSettingsLinkLocalIPv6Address :: Text
403 , networkSettingsLinkLocalIPv6PrefixLen :: Int
402 , networkSettingsLinkLocalIPv6PrefixLen :: Int
404− , networkSettingsPorts :: [Port] -- TODO: 1.24 spec is unclear
403+ , networkSettingsPorts :: PortBindings
405 , networkSettingsSandboxKey :: Text
404 , networkSettingsSandboxKey :: Text
406 , networkSettingsSecondaryIPAddresses :: Maybe [Text] -- TODO: 1.24 spec is unclear
405 , networkSettingsSecondaryIPAddresses :: Maybe [Text] -- TODO: 1.24 spec is unclear
407 , networkSettingsSecondaryIPv6Addresses :: Maybe [Text] -- TODO: 1.24 spec is unclear
406 , networkSettingsSecondaryIPv6Addresses :: Maybe [Text] -- TODO: 1.24 spec is unclear
@@ -411,8 +410,8 @@ data NetworkSettings = NetworkSettings {
411 , networkSettingsGlobalIPv6PrefixLen :: Int
410 , networkSettingsGlobalIPv6PrefixLen :: Int
412 , networkSettingsIpAddress :: Text
411 , networkSettingsIpAddress :: Text
413 , networkSettingsIpPrefixLen :: Int
412 , networkSettingsIpPrefixLen :: Int
414− , networkSettingsIpv6Gateway
413+ , networkSettingsIpv6Gateway :: Text
415− , networkSettingsMacAddress
414+ , networkSettingsMacAddress :: Text
416 , networkSettingsNetworks :: Networks
415 , networkSettingsNetworks :: Networks
417 }
416 }
418 deriving (Eq, Show)
417 deriving (Eq, Show)
@@ -424,7 +423,7 @@ instance FromJSON NetworkSettings where
424 hairpin <- o .: "HairpinMode"
423 hairpin <- o .: "HairpinMode"
425 localIP6 <- o .: "LinkLocalIPv6Address"
424 localIP6 <- o .: "LinkLocalIPv6Address"
426 localIP6Len <- o .: "LinkLocalIPv6PrefixLen"
425 localIP6Len <- o .: "LinkLocalIPv6PrefixLen"
427− ports <- o .:? "Ports" .!= []
426+ ports <- o .: "Ports" -- .!= []
428 sandboxKey <- o .: "SandboxKey"
427 sandboxKey <- o .: "SandboxKey"
429 secondaryIP <- o .: "SecondaryIPAddresses"
428 secondaryIP <- o .: "SecondaryIPAddresses"
430 secondayIP6 <- o .: "SecondaryIPv6Addresses"
429 secondayIP6 <- o .: "SecondaryIPv6Addresses"
@@ -438,7 +437,7 @@ instance FromJSON NetworkSettings where
438 mac <- o .: "MacAddress"
437 mac <- o .: "MacAddress"
439 networks <- o .: "Networks"
438 networks <- o .: "Networks"
440 return $ NetworkSettings bridge sandbox hairpin localIP6 localIP6Len ports sandboxKey secondaryIP secondayIP6 endpointID gateway globalIP6 globalIP6Len ip ipLen ip6Gateway mac networks
439 return $ NetworkSettings bridge sandbox hairpin localIP6 localIP6Len ports sandboxKey secondaryIP secondayIP6 endpointID gateway globalIP6 globalIP6Len ip ipLen ip6Gateway mac networks
441− parseJSON _ = fail "NetworkSettings is not an Object"
440+ parseJSON _ = fail "NetworkSettings is not an object."
442
441
443data Container = Container
442data Container = Container
444 { containerId :: ContainerID
443 { containerId :: ContainerID
@@ -539,7 +538,7 @@ defaultContainerConfig imageName = ContainerConfig {
539 , attachStdout=False
538 , attachStdout=False
540 , image=imageName
539 , image=imageName
541 , attachStderr=False
540 , attachStderr=False
542− , exposedPorts=ExposedPorts M.empty
541+ , exposedPorts=Nothing -- ExposedPorts M.empty
543 , tty=False
542 , tty=False
544 , openStdin=False
543 , openStdin=False
545 , stdinOnce=False
544 , stdinOnce=False
@@ -548,7 +547,7 @@ defaultContainerConfig imageName = ContainerConfig {
548 , volumes=Nothing
547 , volumes=Nothing
549 , workingDir=Nothing
548 , workingDir=Nothing
550 , entrypoint=Nothing
549 , entrypoint=Nothing
551− , networkDisabled=False
550+ , networkDisabled=Nothing
552 , macAddress=Nothing
551 , macAddress=Nothing
553 , labels=Nothing
552 , labels=Nothing
554 , stopSignal=SIGTERM
553 , stopSignal=SIGTERM
@@ -575,7 +574,7 @@ defaultHostConfig = HostConfig {
575 , oomScoreAdj=Nothing
574 , oomScoreAdj=Nothing
576 , privileged=False
575 , privileged=False
577 , publishAllPorts=False
576 , publishAllPorts=False
578− , readOnlyRootfs=False
577+ , readonlyRootfs=False
579 , securityOpt=[]
578 , securityOpt=[]
580 , shmSize=Nothing
579 , shmSize=Nothing
581 , resources=defaultContainerResources
580 , resources=defaultContainerResources
@@ -804,14 +803,14 @@ instance FromJSON PortType where
804 "udp" -> return UDP
803 "udp" -> return UDP
805 _ -> fail "PortType: Invalid port type."
804 _ -> fail "PortType: Invalid port type."
806
805
807−newtype NetworkInterface = NetworkInterface Text deriving (Eq, Show)
806+-- newtype NetworkInterface = NetworkInterface Text deriving (Eq, Show)
808−
807+--
809−instance FromJSON NetworkInterface where
808+-- instance FromJSON NetworkInterface where
810− parseJSON (JSON.String v) = return $ NetworkInterface v
809+-- parseJSON (JSON.String v) = return $ NetworkInterface v
811− parseJSON _ = fail "Network interface is not a string."
810+-- parseJSON _ = fail "Network interface is not a string."
812−
811+--
813−instance ToJSON NetworkInterface where
812+-- instance ToJSON NetworkInterface where
814− toJSON (NetworkInterface i) = JSON.String i
813+-- toJSON (NetworkInterface i) = JSON.String i
815
814
816-- | This datastructure models mapping a Port from the container onto the
815-- | This datastructure models mapping a Port from the container onto the
817-- host system s that the service running in the container can be accessed from
816-- host system s that the service running in the container can be accessed from
@@ -824,7 +823,7 @@ newtype PortBindings = PortBindings [PortBinding]
824data PortBinding = PortBinding {
823data PortBinding = PortBinding {
825 containerPort :: Port
824 containerPort :: Port
826 , portType :: PortType
825 , portType :: PortType
827− , hostPorts :: HostPorts
826+ , hostPorts :: [HostPort]
828 } deriving (Eq, Show)
827 } deriving (Eq, Show)
829
828
830
829
@@ -854,37 +853,39 @@ instance ToJSON PortBindings where
854 toJSON (PortBindings []) = JSON.Object HM.empty
853 toJSON (PortBindings []) = JSON.Object HM.empty
855 toJSON (PortBindings (p:ps)) = toJSON (p:ps)
854 toJSON (PortBindings (p:ps)) = toJSON (p:ps)
856
855
857−data HostPort = HostPort NetworkInterface Port
856+data HostPort = HostPort {
857+ hostIp :: Text
858+ , hostPost :: Port
859+ }
858 deriving (Eq, Show)
860 deriving (Eq, Show)
859
861
860instance ToJSON HostPort where
862instance ToJSON HostPort where
861− toJSON (HostPort i p) = object ["HostPort" .= p, "HostIP" .= i]
863+ toJSON (HostPort i p) = object ["HostPort" .= show p, "HostIp" .= i]
862
864
863instance FromJSON HostPort where
865instance FromJSON HostPort where
864 parseJSON (JSON.Object o) = do
866 parseJSON (JSON.Object o) = do
865− p <- o .: "HostPort"
867+ p <- o .: "HostPort" >>= parseIntegerText
866− i <- o .: "HostIP"
868+ i <- o .: "HostIp"
867 return $ HostPort i p
869 return $ HostPort i p
868 parseJSON _ = fail "HostPort is not an object."
870 parseJSON _ = fail "HostPort is not an object."
869
871
870−newtype HostPorts = HostPorts [HostPort]
872+-- newtype HostPorts = HostPorts [HostPort]
871− deriving (Eq, Show)
873+-- deriving (Eq, Show)
872−
874+--
873−
874−instance ToJSON HostPorts where
875+-- instance ToJSON HostPorts where
875− toJSON (HostPorts hps) = toJSON hps
876+-- toJSON (HostPorts hps) = toJSON hps
876−
877+--
877−instance FromJSON HostPorts where
878+-- instance FromJSON HostPorts where
878− parseJSON (JSON.Object o) = do
879+-- parseJSON (JSON.Object o) = do
879− HostPorts <$> HM.foldlWithKey' f (return []) o
880+-- HostPorts <$> HM.foldlWithKey' f (return []) o
880−
881+--
881− where
882+-- where
882− f accM k v = do
883+-- f accM k v = do
883− acc <- accM
884+-- acc <- accM
884− p' <- parseJSON v
885+-- p' <- parseJSON v
885− p <- parseIntegerText p'
886+-- p <- parseIntegerText p'
886− return $ (HostPort (NetworkInterface k) p):acc
887+-- return $ (HostPort (NetworkInterface k) p):acc
887− parseJSON _ = fail "HostPorts is not an object"
888+-- parseJSON _ = fail $ "HostPorts is not an object"
888
889
889-- { "Name": "on-failure" , "MaximumRetryCount": 2}
890-- { "Name": "on-failure" , "MaximumRetryCount": 2}
890type RetryCount = Integer
891type RetryCount = Integer
@@ -899,7 +900,7 @@ instance FromJSON RestartPolicy where
899 "on-failure" -> do
900 "on-failure" -> do
900 retry <- o .: "MaximumRetryCount"
901 retry <- o .: "MaximumRetryCount"
901 return $ RestartOnFailure retry
902 return $ RestartOnFailure retry
902− "" -> return RestartOff -- Note: Is this correct? 1.24 spec is unclear.
903+ "off" -> return RestartOff
903 _ -> fail "Could not parse RestartPolicy"
904 _ -> fail "Could not parse RestartPolicy"
904 parseJSON _ = fail "RestartPolicy is not an object"
905 parseJSON _ = fail "RestartPolicy is not an object"
905
906
@@ -938,7 +939,7 @@ data HostConfig = HostConfig
938 -- , pidMode :: Text -- 1.24: Don't see pidMode, just pidsLimit
939 -- , pidMode :: Text -- 1.24: Don't see pidMode, just pidsLimit
939 , privileged :: Bool
940 , privileged :: Bool
940 , publishAllPorts :: Bool
941 , publishAllPorts :: Bool
941− , readOnlyRootfs :: Bool
942+ , readonlyRootfs :: Bool
942 , securityOpt :: [Text]
943 , securityOpt :: [Text]
943 -- , utsMode :: UTSMode -- 1.24: Don't see this
944 -- , utsMode :: UTSMode -- 1.24: Don't see this
944 , shmSize :: Maybe Integer
945 , shmSize :: Maybe Integer
@@ -948,12 +949,84 @@ data HostConfig = HostConfig
948 } deriving (Eq, Show, Generic)
949 } deriving (Eq, Show, Generic)
949
950
950instance FromJSON HostConfig where
951instance FromJSON HostConfig where
951− parseJSON = genericParseJSON defaultOptions {
952+ parseJSON v@(JSON.Object o) = HostConfig
952− fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
953+ <$> o .: "Binds"
954+ <*> o .: "ContainerIDFile"
955+ <*> o .: "LogConfig"
956+ <*> o .: "NetworkMode"
957+ <*> o .: "PortBindings"
958+ <*> o .: "RestartPolicy"
959+ <*> o .: "VolumeDriver"
960+ <*> o .: "VolumesFrom"
961+ <*> o .: "CapAdd"
962+ <*> o .: "CapDrop"
963+ <*> o .: "Dns"
964+ <*> o .: "DnsOptions"
965+ <*> o .: "DnsSearch"
966+ <*> o .: "ExtraHosts"
967+ <*> o .: "IpcMode"
968+ <*> o .:? "Links" .!= []
969+ <*> o .: "OomScoreAdj"
970+ <*> o .: "Privileged"
971+ <*> o .: "PublishAllPorts"
972+ <*> o .: "ReadonlyRootfs"
973+ <*> o .: "SecurityOpt"
974+ <*> o .: "ShmSize"
975+ <*> parseJSON v
976+ parseJSON _ = fail "HostConfig is not an object."
953
977
954instance ToJSON HostConfig where
978instance ToJSON HostConfig where
955− toJSON = genericToJSON defaultOptions {
979+ toJSON HostConfig{..} =
956− fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
980+ let arr = [
981+ "Binds" .= binds
982+ , "ContainerIDFile" .= containerIDFile
983+ , "LogConfig" .= logConfig
984+ , "NetworkMode" .= networkMode
985+ , "PortBindings" .= portBindings
986+ , "RestartPolicy" .= restartPolicy
987+ , "VolumeDriver" .= volumeDriver
988+ , "VolumesFrom" .= volumesFrom
989+ , "CapAdd" .= capAdd
990+ , "CapDrop" .= capDrop
991+ , "Dns" .= dns
992+ , "DnsOptions" .= dnsOptions
993+ , "DnsSearch" .= dnsSearch
994+ , "ExtraHosts" .= extraHosts
995+ , "IpcMode" .= ipcMode
996+ , "Links" .= links
997+ , "OomScoreAdj" .= oomScoreAdj
998+ , "Privileged" .= privileged
999+ , "PublishAllPorts" .= publishAllPorts
1000+ , "ReadonlyRootfs" .= readonlyRootfs
1001+ , "SecurityOpt" .= securityOpt
1002+ , "ShmSize" .= shmSize
1003+ ]
1004+ in
1005+ object $ arr <> ( resourcesArr resources)
1006+
1007+ where
1008+ -- JP: Not sure if this is better than a separate ToJSON instance with a bunch of `HM.insert`s.
1009+ resourcesArr ContainerResources{..} = [
1010+ "CpuShares" .= cpuShares
1011+ , "BlkioWeight" .= blkioWeight
1012+ , "BlkioWeightDevice" .= blkioWeightDevice
1013+ , "BlkioDeviceReadBps" .= blkioDeviceReadBps
1014+ , "BlkioDeviceWriteBps" .= blkioDeviceWriteBps
1015+ , "BlkioDeviceReadIOps" .= blkioDeviceReadIOps
1016+ , "BlkioDeviceWriteIOps" .= blkioDeviceWriteIOps
1017+ , "CpuPeriod" .= cpuPeriod
1018+ , "CpusetCpus" .= cpusetCpus
1019+ , "CpusetMems" .= cpusetMems
1020+ , "Devices" .= devices
1021+ , "KernelMemory" .= kernelMemory
1022+ , "Memory" .= memory
1023+ , "MemoryReservation" .= memoryReservation
1024+ , "MemorySwap" .= memorySwap
1025+ , "OomKillDisable" .= oomKillDisable
1026+ , "Ulimits" .= ulimits
1027+ ]
1028+
1029+
957
1030
958
1031
959-- { "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }
1032-- { "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }
@@ -972,18 +1045,54 @@ instance ToJSON Ulimit where
972 toJSON = genericToJSON defaultOptions {
1045 toJSON = genericToJSON defaultOptions {
973 fieldLabelModifier = drop 5}
1046 fieldLabelModifier = drop 5}
974
1047
1048+data DeviceWeight = DeviceWeight {
1049+ deviceWeightPath :: FilePath
1050+ , deviceWeightWeight :: Text
1051+ }
1052+ deriving (Show, Eq)
1053+
1054+instance FromJSON DeviceWeight where
1055+ parseJSON (JSON.Object o) = DeviceWeight
1056+ <$> o .: "Path"
1057+ <*> o .: "Weight"
1058+ parseJSON _ = fail "DeviceWeight is not an object."
1059+
1060+instance ToJSON DeviceWeight where
1061+ toJSON (DeviceWeight p w) = object [
1062+ "Path" .= p
1063+ , "Weight" .= w
1064+ ]
1065+
1066+data DeviceRate = DeviceRate {
1067+ deviceRatePath :: FilePath
1068+ , deviceRateRate :: Text
1069+ }
1070+ deriving (Show, Eq)
1071+
1072+instance FromJSON DeviceRate where
1073+ parseJSON (JSON.Object o) = DeviceRate
1074+ <$> o .: "Path"
1075+ <*> o .: "Rate"
1076+ parseJSON _ = fail "DeviceRate is not an object."
1077+
1078+instance ToJSON DeviceRate where
1079+ toJSON (DeviceRate p r) = object [
1080+ "Path" .= p
1081+ , "Rate" .= r
1082+ ]
1083+
975data ContainerResources = ContainerResources {
1084data ContainerResources = ContainerResources {
976 cpuShares :: Maybe Integer
1085 cpuShares :: Maybe Integer
977 -- , cgroupParent :: Text -- 1.24: Missing from inspecting container details... Going to omit for now.
1086 -- , cgroupParent :: Text -- 1.24: Missing from inspecting container details... Going to omit for now.
978− , blkioWeight :: Maybe Text
1087+ , blkioWeight :: Maybe Integer
979− , blkioWeightDevice :: Maybe Text
1088+ , blkioWeightDevice :: Maybe [DeviceWeight]
980− , blkioDeviceReadBps :: Maybe Text
1089+ , blkioDeviceReadBps :: Maybe [DeviceRate] -- TODO: Not Text
981− , blkioDeviceWriteBps :: Maybe Text
1090+ , blkioDeviceWriteBps :: Maybe [DeviceRate] -- TODO: Not Text
982− , blkioDeviceReadIOps :: Maybe Text
1091+ , blkioDeviceReadIOps :: Maybe [DeviceRate] -- TODO: Not Text
983− , blkioDeviceWriteIOps :: Maybe Text
1092+ , blkioDeviceWriteIOps :: Maybe [DeviceRate] -- TODO: Not Text
984 , cpuPeriod :: Maybe Integer
1093 , cpuPeriod :: Maybe Integer
985 -- , cpuQuota :: Integer -- 1.24: Missing from inspecting container details... Going to omit for now.
1094 -- , cpuQuota :: Integer -- 1.24: Missing from inspecting container details... Going to omit for now.
986− , cpusetCpus :: Maybe Integer
1095+ , cpusetCpus :: Maybe Text
987 , cpusetMems :: Maybe Text
1096 , cpusetMems :: Maybe Text
988 , devices :: [Device]
1097 , devices :: [Device]
989 -- , diskQuota :: Integer -- Don't see this ins 1.24.
1098 -- , diskQuota :: Integer -- Don't see this ins 1.24.
@@ -1006,13 +1115,13 @@ data ContainerResources = ContainerResources {
1006 -- LxcConf :: [??] +
1115 -- LxcConf :: [??] +
1007 } deriving (Eq, Show, Generic)
1116 } deriving (Eq, Show, Generic)
1008
1117
1009−instance ToJSON ContainerResources where
1118+-- instance ToJSON ContainerResources where
1010− toJSON = genericToJSON defaultOptions {
1119+-- toJSON = genericToJSON defaultOptions {
1011− fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
1120+-- fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
1012
1121
1013instance FromJSON ContainerResources where
1122instance FromJSON ContainerResources where
1014 parseJSON = genericParseJSON defaultOptions {
1123 parseJSON = genericParseJSON defaultOptions {
1015− fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
1124+ fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
1016
1125
1017type Port = Integer
1126type Port = Integer
1018
1127
@@ -1074,7 +1183,7 @@ data ContainerConfig = ContainerConfig {
1074 , attachStdin :: Bool
1183 , attachStdin :: Bool
1075 , attachStdout :: Bool
1184 , attachStdout :: Bool
1076 , attachStderr :: Bool
1185 , attachStderr :: Bool
1077− , exposedPorts :: ExposedPorts
1186+ , exposedPorts :: Maybe ExposedPorts -- Note: Should we expand the JSON instance and take away the Maybe?
1078 -- , publishService :: Text -- Don't see this in 1.24
1187 -- , publishService :: Text -- Don't see this in 1.24
1079 , tty :: Bool
1188 , tty :: Bool
1080 , openStdin :: Bool
1189 , openStdin :: Bool
@@ -1086,9 +1195,9 @@ data ContainerConfig = ContainerConfig {
1086 , volumes :: Maybe Volumes
1195 , volumes :: Maybe Volumes
1087 , workingDir :: Maybe FilePath
1196 , workingDir :: Maybe FilePath
1088 , entrypoint :: Maybe Text -- Can be null?
1197 , entrypoint :: Maybe Text -- Can be null?
1089− , networkDisabled :: Bool
1198+ , networkDisabled :: Maybe Bool -- Note: Should we expand the JSON instance and take away the Maybe? Null is False?
1090 , macAddress :: Maybe Text
1199 , macAddress :: Maybe Text
1091− -- , onBuild :: Text -- For 1.24, only see this in the inspect response.
1200+ -- , onBuild :: Maybe Text -- For 1.24, only see this in the inspect response.
1092 , labels :: Maybe Labels
1201 , labels :: Maybe Labels
1093 , stopSignal :: Signal
1202 , stopSignal :: Signal
1094 } deriving (Eq, Show, Generic)
1203 } deriving (Eq, Show, Generic)
@@ -1101,7 +1210,7 @@ instance FromJSON ContainerConfig where
1101 parseJSON = genericParseJSON defaultOptions {
1210 parseJSON = genericParseJSON defaultOptions {
1102 fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
1211 fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
1103
1212
1104−parseIntegerText :: (Monad m) =>Text -> m Integer
1213+parseIntegerText :: (Monad m) => Text -> m Integer
1105parseIntegerText t = case readMaybe $ T.unpack t of
1214parseIntegerText t = case readMaybe $ T.unpack t of
1106 Nothing ->
1215 Nothing ->
1107 fail "Could not parse Integer"
1216 fail "Could not parse Integer"
tests/tests.hs+1
@@ -60,6 +60,7 @@ testRunAndReadLog = runDocker $ do
60 containerId <- createContainer (defaultCreateOpts (testImageName <> ":latest"))
60 containerId <- createContainer (defaultCreateOpts (testImageName <> ":latest"))
61 c <- fromRight containerId
61 c <- fromRight containerId
62 status1 <- startContainer defaultStartOpts c
62 status1 <- startContainer defaultStartOpts c
63+ _ <- inspectContainer c >>= fromRight
63 lift $ threadDelay 300000 -- give 300ms for the application to finish
64 lift $ threadDelay 300000 -- give 300ms for the application to finish
64 lift $ assert $ status1 == Right ()
65 lift $ assert $ status1 == Right ()
65 status2 <- killContainer SIGTERM c
66 status2 <- killContainer SIGTERM c