on master help sign in
Makes use of .!= for json defaults
commit5431003828f8cc2736b852c85e3985b56d5112f7 authorDeni Bertovic <deni@denibertovic.com> dateTue 6 Sep 2016, 21:52 (10 years ago) parentd28e646
1 file changed+3−9
src/Docker/Client/Types.hs+3−9
src/Docker/Client/Types.hs+3−9
@@ -582,9 +582,7 @@ instance FromJSON Image where
582582 imageRepoDigests <- o .:? "RepoDigests" .!= []
583583 imageSize <- o .: "Size"
584584 imageVirtualSize <- o .: "VirtualSize"
585− imageLabels <- case HM.lookup "Labels" o of
586− Just ls -> parseJSON ls
587− Nothing -> return []
585+ imageLabels <- o .:? "Labels" .!= []
588586 return $ DockerImage imageId imageCreated imageParentId imageRepoTags imageRepoDigests imageSize imageVirtualSize imageLabels
589587 parseJSON _ = fail "Failed to parse DockerImage."
590588
@@ -1381,9 +1379,7 @@ instance FromJSON ContainerConfig where
13811379 attachStdin <- o .: "AttachStdin"
13821380 attachStdout <- o .: "AttachStdout"
13831381 attachStderr <- o .: "AttachStderr"
1384− exposedPorts <- case HM.lookup "ExposedPorts" o of
1385− Just eps -> parseJSON eps
1386− Nothing -> return []
1382+ exposedPorts <- o .:? "ExposedPorts" .!= []
13871383 tty <- o .: "Tty"
13881384 openStdin <- o .: "OpenStdin"
13891385 stdinOnce <- o .: "StdinOnce"
@@ -1395,9 +1391,7 @@ instance FromJSON ContainerConfig where
13951391 entrypoint <- o .:? "Entrypoint"
13961392 networkDisabled <- o .:? "networkDisabled"
13971393 macAddress <- o .:? "MacAddress"
1398− labels <- case HM.lookup "Labels" o of
1399− Just ls -> parseJSON ls
1400− Nothing -> return []
1394+ labels <- o .:? "Labels" .!= []
14011395 stopSignal <- o .: "StopSignal"
14021396 return $ ContainerConfig hostname domainname user attachStdin attachStdout attachStderr exposedPorts tty openStdin stdinOnce env cmd image volumes workingDir entrypoint networkDisabled
14031397 macAddress labels stopSignal