on master help sign in
Gets rid of NoEntrypoint constructor

since it's the same as Entrypoint []

commitf5f50fab094509d0002fec5bd4035f91aed578e6 authorDeni Bertovic <deni@denibertovic.com> dateThu 23 Mar 2017, 12:03 (10 years ago) parent8b97334
2 files changed+6−9
src/Docker/Client/Types.hs+4−7 tests/tests.hs+2−2
src/Docker/Client/Types.hs+4−7
@@ -645,7 +645,7 @@ defaultContainerConfig imageName = ContainerConfig {
645645 , cmd=[]
646646 , volumes=[]
647647 , workingDir=Nothing
648− , entrypoint=NoEntrypoint
648+ , entrypoint=Entrypoint []
649649 , networkDisabled=Nothing
650650 , macAddress=Nothing
651651 , labels=[]
@@ -1388,10 +1388,9 @@ instance {-# OVERLAPPING #-} ToJSON [ExposedPort] where
13881388 where key (ExposedPort p t) = show p <> slash <> show t
13891389 slash = T.unpack "/"
13901390
1391−data Entrypoint = Entrypoint [T.Text] | NoEntrypoint deriving (Eq, Show, Generic)
1391+data Entrypoint = Entrypoint [T.Text] deriving (Eq, Show, Generic)
13921392
13931393instance ToJSON Entrypoint where
1394− toJSON NoEntrypoint = JSON.Null
13951394 toJSON (Entrypoint (e:es)) = toJSON (e:es)
13961395 toJSON (Entrypoint []) = JSON.Null
13971396
@@ -1399,10 +1398,8 @@ instance FromJSON Entrypoint where
13991398 parseJSON (JSON.String e) = return $ Entrypoint [e]
14001399 parseJSON (JSON.Array ar) = do
14011400 arr <- mapM parseJSON (V.toList ar)
1402− case arr of
1403− [] -> return NoEntrypoint
1404− (e:es) -> return $ Entrypoint (e:es)
1405− parseJSON JSON.Null = return NoEntrypoint
1401+ return $ Entrypoint arr
1402+ parseJSON JSON.Null = return $ Entrypoint []
14061403 parseJSON _ = fail "Failed to parse Entrypoint"
14071404
14081405
tests/tests.hs+2−2
@@ -134,7 +134,7 @@ testEntrypointJson :: TestTree
134134testEntrypointJson = testGroup "Testing ContainerConfig JSON" [testSample1, testSample2, testSample3, testSample4, testSample5]
135135 where
136136 testSample1 =
137− testCase "Test toJSON with empty entrypoint (null)" $ assert $ JSON.toJSON NoEntrypoint ^. _Null == ()
137+ testCase "Test toJSON with empty entrypoint (null)" $ assert $ JSON.toJSON (Entrypoint []) ^. _Null == ()
138138 testSample2 =
139139 testCase "Test toJSON with entrypoint as Array" $ assert $
140140 JSON.toJSON (Entrypoint sampleEntrypointArr) ==
@@ -144,7 +144,7 @@ testEntrypointJson = testGroup "Testing ContainerConfig JSON" [testSample1, test
144144 Just (Entrypoint ["cmd"])
145145 testSample4 =
146146 testCase "Test decoding as null" $ assert $ (JSON.decode "null" :: Maybe Entrypoint) ==
147− Just NoEntrypoint
147+ Just (Entrypoint [])
148148 testSample5 =
149149 testCase "Test decoding as array" $ assert $ (JSON.decode (JSON.encode sampleEntrypointArr) :: Maybe Entrypoint) ==
150150 Just (Entrypoint sampleEntrypointArr)