on master help sign in
Makes use of .!= for json defaults
5431003Deni Bertovic
src/Docker/Client/Types.hs+3−9
@@ -582,9 +582,7 @@ instance FromJSON Image where
582 imageRepoDigests <- o .:? "RepoDigests" .!= []
582 imageRepoDigests <- o .:? "RepoDigests" .!= []
583 imageSize <- o .: "Size"
583 imageSize <- o .: "Size"
584 imageVirtualSize <- o .: "VirtualSize"
584 imageVirtualSize <- o .: "VirtualSize"
585− imageLabels <- case HM.lookup "Labels" o of
585+ imageLabels <- o .:? "Labels" .!= []
586− Just ls -> parseJSON ls
587− Nothing -> return []
588 return $ DockerImage imageId imageCreated imageParentId imageRepoTags imageRepoDigests imageSize imageVirtualSize imageLabels
586 return $ DockerImage imageId imageCreated imageParentId imageRepoTags imageRepoDigests imageSize imageVirtualSize imageLabels
589 parseJSON _ = fail "Failed to parse DockerImage."
587 parseJSON _ = fail "Failed to parse DockerImage."
590
588
@@ -1381,9 +1379,7 @@ instance FromJSON ContainerConfig where
1381 attachStdin <- o .: "AttachStdin"
1379 attachStdin <- o .: "AttachStdin"
1382 attachStdout <- o .: "AttachStdout"
1380 attachStdout <- o .: "AttachStdout"
1383 attachStderr <- o .: "AttachStderr"
1381 attachStderr <- o .: "AttachStderr"
1384− exposedPorts <- case HM.lookup "ExposedPorts" o of
1382+ exposedPorts <- o .:? "ExposedPorts" .!= []
1385− Just eps -> parseJSON eps
1386− Nothing -> return []
1387 tty <- o .: "Tty"
1383 tty <- o .: "Tty"
1388 openStdin <- o .: "OpenStdin"
1384 openStdin <- o .: "OpenStdin"
1389 stdinOnce <- o .: "StdinOnce"
1385 stdinOnce <- o .: "StdinOnce"
@@ -1395,9 +1391,7 @@ instance FromJSON ContainerConfig where
1395 entrypoint <- o .:? "Entrypoint"
1391 entrypoint <- o .:? "Entrypoint"
1396 networkDisabled <- o .:? "networkDisabled"
1392 networkDisabled <- o .:? "networkDisabled"
1397 macAddress <- o .:? "MacAddress"
1393 macAddress <- o .:? "MacAddress"
1398− labels <- case HM.lookup "Labels" o of
1394+ labels <- o .:? "Labels" .!= []
1399− Just ls -> parseJSON ls
1400− Nothing -> return []
1401 stopSignal <- o .: "StopSignal"
1395 stopSignal <- o .: "StopSignal"
1402 return $ ContainerConfig hostname domainname user attachStdin attachStdout attachStderr exposedPorts tty openStdin stdinOnce env cmd image volumes workingDir entrypoint networkDisabled
1396 return $ ContainerConfig hostname domainname user attachStdin attachStdout attachStderr exposedPorts tty openStdin stdinOnce env cmd image volumes workingDir entrypoint networkDisabled
1403 macAddress labels stopSignal
1397 macAddress labels stopSignal