on master help sign in
Gets rid of NoEntrypoint constructor
f5f50faDeni Bertovic
src/Docker/Client/Types.hs+4−7
@@ -645,7 +645,7 @@ defaultContainerConfig imageName = ContainerConfig {
645 , cmd=[]
645 , cmd=[]
646 , volumes=[]
646 , volumes=[]
647 , workingDir=Nothing
647 , workingDir=Nothing
648− , entrypoint=NoEntrypoint
648+ , entrypoint=Entrypoint []
649 , networkDisabled=Nothing
649 , networkDisabled=Nothing
650 , macAddress=Nothing
650 , macAddress=Nothing
651 , labels=[]
651 , labels=[]
@@ -1388,10 +1388,9 @@ instance {-# OVERLAPPING #-} ToJSON [ExposedPort] where
1388 where key (ExposedPort p t) = show p <> slash <> show t
1388 where key (ExposedPort p t) = show p <> slash <> show t
1389 slash = T.unpack "/"
1389 slash = T.unpack "/"
1390
1390
1391−data Entrypoint = Entrypoint [T.Text] | NoEntrypoint deriving (Eq, Show, Generic)
1391+data Entrypoint = Entrypoint [T.Text] deriving (Eq, Show, Generic)
1392
1392
1393instance ToJSON Entrypoint where
1393instance ToJSON Entrypoint where
1394− toJSON NoEntrypoint = JSON.Null
1395 toJSON (Entrypoint (e:es)) = toJSON (e:es)
1394 toJSON (Entrypoint (e:es)) = toJSON (e:es)
1396 toJSON (Entrypoint []) = JSON.Null
1395 toJSON (Entrypoint []) = JSON.Null
1397
1396
@@ -1399,10 +1398,8 @@ instance FromJSON Entrypoint where
1399 parseJSON (JSON.String e) = return $ Entrypoint [e]
1398 parseJSON (JSON.String e) = return $ Entrypoint [e]
1400 parseJSON (JSON.Array ar) = do
1399 parseJSON (JSON.Array ar) = do
1401 arr <- mapM parseJSON (V.toList ar)
1400 arr <- mapM parseJSON (V.toList ar)
1402− case arr of
1401+ return $ Entrypoint arr
1403− [] -> return NoEntrypoint
1404− (e:es) -> return $ Entrypoint (e:es)
1405− parseJSON JSON.Null = return NoEntrypoint
1402+ parseJSON JSON.Null = return $ Entrypoint []
1406 parseJSON _ = fail "Failed to parse Entrypoint"
1403 parseJSON _ = fail "Failed to parse Entrypoint"
1407
1404
1408
1405
tests/tests.hs+2−2
@@ -134,7 +134,7 @@ testEntrypointJson :: TestTree
134testEntrypointJson = testGroup "Testing ContainerConfig JSON" [testSample1, testSample2, testSample3, testSample4, testSample5]
134testEntrypointJson = testGroup "Testing ContainerConfig JSON" [testSample1, testSample2, testSample3, testSample4, testSample5]
135 where
135 where
136 testSample1 =
136 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 == ()
138 testSample2 =
138 testSample2 =
139 testCase "Test toJSON with entrypoint as Array" $ assert $
139 testCase "Test toJSON with entrypoint as Array" $ assert $
140 JSON.toJSON (Entrypoint sampleEntrypointArr) ==
140 JSON.toJSON (Entrypoint sampleEntrypointArr) ==
@@ -144,7 +144,7 @@ testEntrypointJson = testGroup "Testing ContainerConfig JSON" [testSample1, test
144 Just (Entrypoint ["cmd"])
144 Just (Entrypoint ["cmd"])
145 testSample4 =
145 testSample4 =
146 testCase "Test decoding as null" $ assert $ (JSON.decode "null" :: Maybe Entrypoint) ==
146 testCase "Test decoding as null" $ assert $ (JSON.decode "null" :: Maybe Entrypoint) ==
147− Just NoEntrypoint
147+ Just (Entrypoint [])
148 testSample5 =
148 testSample5 =
149 testCase "Test decoding as array" $ assert $ (JSON.decode (JSON.encode sampleEntrypointArr) :: Maybe Entrypoint) ==
149 testCase "Test decoding as array" $ assert $ (JSON.decode (JSON.encode sampleEntrypointArr) :: Maybe Entrypoint) ==
150 Just (Entrypoint sampleEntrypointArr)
150 Just (Entrypoint sampleEntrypointArr)