@@ -282,11 +282,8 @@ instance FromJSON DockerVersion where
282 parseJSON = genericParseJSON defaultOptions {
282 parseJSON = genericParseJSON defaultOptions {
283 fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
283 fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
285−-- instance ToJSON ContainerDetails where
286−-- toJSON = error "TODO"
288instance FromJSON ContainerDetails where
285instance FromJSON ContainerDetails where
289− parseJSON (JSON.Object o) = do
286+ parseJSON v@(JSON.Object o) = do
290 appArmor <- o .: "AppArmorProfile"
287 appArmor <- o .: "AppArmorProfile"
291 args <- o .: "Args"
288 args <- o .: "Args"
292 config <- o .: "Config"
289 config <- o .: "Config"
@@ -296,7 +293,7 @@ instance FromJSON ContainerDetails where
296 hostnamePath <- o .: "HostnamePath"
293 hostnamePath <- o .: "HostnamePath"
297 hostsPath <- o .: "HostsPath"
294 hostsPath <- o .: "HostsPath"
298 logPath <- o .: "LogPath"
295 logPath <- o .: "LogPath"
299− id <- o .: "Id"
296+ id <- parseJSON v
300 image <- o .: "Image"
297 image <- o .: "Image"
301 mountLabel <- o .: "MountLabel"
298 mountLabel <- o .: "MountLabel"
302 name <- o .: "Name"
299 name <- o .: "Name"
@@ -401,7 +398,7 @@ data NetworkSettings = NetworkSettings {
401 , networkSettingsHairpinMode :: Bool
398 , networkSettingsHairpinMode :: Bool
402 , networkSettingsLinkLocalIPv6Address :: Text
399 , networkSettingsLinkLocalIPv6Address :: Text
403 , networkSettingsLinkLocalIPv6PrefixLen :: Int
400 , networkSettingsLinkLocalIPv6PrefixLen :: Int
404− , networkSettingsPorts :: [Port] -- TODO: 1.24 spec is unclear
401+ , networkSettingsPorts :: PortBindings
405 , networkSettingsSandboxKey :: Text
402 , networkSettingsSandboxKey :: Text
406 , networkSettingsSecondaryIPAddresses :: Maybe [Text] -- TODO: 1.24 spec is unclear
403 , networkSettingsSecondaryIPAddresses :: Maybe [Text] -- TODO: 1.24 spec is unclear
407 , networkSettingsSecondaryIPv6Addresses :: Maybe [Text] -- TODO: 1.24 spec is unclear
404 , networkSettingsSecondaryIPv6Addresses :: Maybe [Text] -- TODO: 1.24 spec is unclear
@@ -424,7 +421,7 @@ instance FromJSON NetworkSettings where
424 hairpin <- o .: "HairpinMode"
421 hairpin <- o .: "HairpinMode"
425 localIP6 <- o .: "LinkLocalIPv6Address"
422 localIP6 <- o .: "LinkLocalIPv6Address"
426 localIP6Len <- o .: "LinkLocalIPv6PrefixLen"
423 localIP6Len <- o .: "LinkLocalIPv6PrefixLen"
427− ports <- o .:? "Ports" .!= []
424+ ports <- o .: "Ports" -- .!= []
428 sandboxKey <- o .: "SandboxKey"
425 sandboxKey <- o .: "SandboxKey"
429 secondaryIP <- o .: "SecondaryIPAddresses"
426 secondaryIP <- o .: "SecondaryIPAddresses"
430 secondayIP6 <- o .: "SecondaryIPv6Addresses"
427 secondayIP6 <- o .: "SecondaryIPv6Addresses"
@@ -438,7 +435,7 @@ instance FromJSON NetworkSettings where
438 mac <- o .: "MacAddress"
435 mac <- o .: "MacAddress"
439 networks <- o .: "Networks"
436 networks <- o .: "Networks"
440 return $ NetworkSettings bridge sandbox hairpin localIP6 localIP6Len ports sandboxKey secondaryIP secondayIP6 endpointID gateway globalIP6 globalIP6Len ip ipLen ip6Gateway mac networks
437 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"
438+ parseJSON _ = fail "NetworkSettings is not an object."
443data Container = Container
440data Container = Container
444 { containerId :: ContainerID
441 { containerId :: ContainerID
@@ -824,7 +821,7 @@ newtype PortBindings = PortBindings [PortBinding]
824data PortBinding = PortBinding {
821data PortBinding = PortBinding {
825 containerPort :: Port
822 containerPort :: Port
826 , portType :: PortType
823 , portType :: PortType
827− , hostPorts :: HostPorts
824+ , hostPorts :: [HostPort]
828 } deriving (Eq, Show)
825 } deriving (Eq, Show)
@@ -862,29 +859,28 @@ instance ToJSON HostPort where
863instance FromJSON HostPort where
860instance FromJSON HostPort where
864 parseJSON (JSON.Object o) = do
861 parseJSON (JSON.Object o) = do
865− p <- o .: "HostPort"
862+ p <- o .: "HostPort" >>= parseIntegerText
866− i <- o .: "HostIP"
863+ i <- o .: "HostIp"
867 return $ HostPort i p
864 return $ HostPort i p
868 parseJSON _ = fail "HostPort is not an object."
865 parseJSON _ = fail "HostPort is not an object."
870−newtype HostPorts = HostPorts [HostPort]
867+-- newtype HostPorts = HostPorts [HostPort]
871− deriving (Eq, Show)
868+-- deriving (Eq, Show)
874−instance ToJSON HostPorts where
870+-- instance ToJSON HostPorts where
875− toJSON (HostPorts hps) = toJSON hps
871+-- toJSON (HostPorts hps) = toJSON hps
877−instance FromJSON HostPorts where
873+-- instance FromJSON HostPorts where
878− parseJSON (JSON.Object o) = do
874+-- parseJSON (JSON.Object o) = do
879− HostPorts <$> HM.foldlWithKey' f (return []) o
875+-- HostPorts <$> HM.foldlWithKey' f (return []) o
882− f accM k v = do
878+-- f accM k v = do
883− acc <- accM
879+-- acc <- accM
884− p' <- parseJSON v
880+-- p' <- parseJSON v
885− p <- parseIntegerText p'
881+-- p <- parseIntegerText p'
886− return $ (HostPort (NetworkInterface k) p):acc
882+-- return $ (HostPort (NetworkInterface k) p):acc
887− parseJSON _ = fail "HostPorts is not an object"
883+-- parseJSON _ = fail $ "HostPorts is not an object"
889-- { "Name": "on-failure" , "MaximumRetryCount": 2}
885-- { "Name": "on-failure" , "MaximumRetryCount": 2}
890type RetryCount = Integer
886type RetryCount = Integer
@@ -1047,12 +1043,12 @@ instance ToJSON Ulimit where
1047data ContainerResources = ContainerResources {
1043data ContainerResources = ContainerResources {
1048 cpuShares :: Maybe Integer
1044 cpuShares :: Maybe Integer
1049 -- , cgroupParent :: Text -- 1.24: Missing from inspecting container details... Going to omit for now.
1045 -- , cgroupParent :: Text -- 1.24: Missing from inspecting container details... Going to omit for now.
1050− , blkioWeight :: Maybe Text
1046+ , blkioWeight :: Maybe Integer
1051− , blkioWeightDevice :: Maybe Text
1047+ , blkioWeightDevice :: Maybe Text -- TODO: Not Text
1052− , blkioDeviceReadBps :: Maybe Text
1048+ , blkioDeviceReadBps :: Maybe Text -- TODO: Not Text
1053− , blkioDeviceWriteBps :: Maybe Text
1049+ , blkioDeviceWriteBps :: Maybe Text -- TODO: Not Text
1054− , blkioDeviceReadIOps :: Maybe Text
1050+ , blkioDeviceReadIOps :: Maybe Text -- TODO: Not Text
1055− , blkioDeviceWriteIOps :: Maybe Text
1051+ , blkioDeviceWriteIOps :: Maybe Text -- TODO: Not Text
1056 , cpuPeriod :: Maybe Integer
1052 , cpuPeriod :: Maybe Integer
1057 -- , cpuQuota :: Integer -- 1.24: Missing from inspecting container details... Going to omit for now.
1053 -- , cpuQuota :: Integer -- 1.24: Missing from inspecting container details... Going to omit for now.
1058 , cpusetCpus :: Maybe Text
1054 , cpusetCpus :: Maybe Text
@@ -1173,7 +1169,7 @@ instance FromJSON ContainerConfig where
1173 parseJSON = genericParseJSON defaultOptions {
1169 parseJSON = genericParseJSON defaultOptions {
1174 fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
1170 fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
1176−parseIntegerText :: (Monad m) =>Text -> m Integer
1172+parseIntegerText :: (Monad m) => Text -> m Integer
1177parseIntegerText t = case readMaybe $ T.unpack t of
1173parseIntegerText t = case readMaybe $ T.unpack t of
1178 Nothing ->
1174 Nothing ->
1179 fail "Could not parse Integer"
1175 fail "Could not parse Integer"