on master help sign in
Adds VolumePermissions (and json instances)
commit08792fda49e4e7552d1956b859a148f6801dbca8 authorDeni Bertovic <deni@denibertovic.com> dateSun 14 Aug 2016, 01:08 (10 years ago) parente17d8e4
1 file changed+16−10
src/Docker/Client/Types.hs+16−10
src/Docker/Client/Types.hs+16−10
@@ -202,7 +202,7 @@ data Mount = Mount {
202202 , mountSource :: FilePath
203203 , mountDestination :: FilePath
204204 , mountDriver :: Text
205− , mountMode :: Text -- Note: Improve this?
205+ , mountMode :: Maybe VolumePermission -- apparently this can be null
206206 , mountRW :: Bool
207207 , mountPropogation :: Text
208208 }
@@ -645,12 +645,18 @@ defaultLogOpts = LogOpts { stdout = True
645645 , tail = All
646646 }
647647
648−data VolumePermission = Rw | Ro deriving (Eq, Show, Generic)
648+-- TOOD: Add support for SELinux Volume labels (eg. "ro,z" or "ro/Z")
649+-- | Set permissions on volumes that you mount in the container.
650+data VolumePermission = ReadWrite | ReadOnly deriving (Eq, Show, Generic)
649651
650−-- instance ToJSON VolumePermission where
651−-- toJSON = error "TODO"
652−-- instance FromJSON VolumePermission where
653−-- parseJSON = error "TODO"
652+instance ToJSON VolumePermission where
653+ toJSON ReadWrite = "rw"
654+ toJSON ReadOnly = "ro"
655+
656+instance FromJSON VolumePermission where
657+ parseJSON "rw" = return ReadWrite
658+ parseJSON "ro" = return ReadOnly
659+ parseJSON _ = fail "Failed to parse VolumePermission"
654660
655661-- | Used for marking a directory in the container as "exposed" hence
656662-- taking it outside of the COW filesystem and making it mountable
@@ -680,8 +686,8 @@ data Volume = Volume { hostSrc :: Text
680686instance FromJSON Volume where
681687 parseJSON (JSON.String t) = case T.split (== ':') t of
682688 [src, dest] -> return $ Volume src dest Nothing
683− [src, dest, "rw"] -> return $ Volume src dest $ Just Rw
684− [src, dest, "ro"] -> return $ Volume src dest $ Just Ro
689+ [src, dest, "rw"] -> return $ Volume src dest $ Just ReadWrite
690+ [src, dest, "ro"] -> return $ Volume src dest $ Just ReadOnly
685691 _ -> fail "Could not parse Volume"
686692 parseJSON _ = fail "Volume is not a string"
687693
@@ -706,8 +712,8 @@ data VolumeFrom = VolumeFrom ContainerName (Maybe VolumePermission) deriving (Eq
706712instance FromJSON VolumeFrom where
707713 parseJSON (JSON.String t) = case T.split (== ':') t of
708714 [vol] -> return $ VolumeFrom vol Nothing
709− [vol, "rw"] -> return $ VolumeFrom vol $ Just Rw
710− [vol, "ro"] -> return $ VolumeFrom vol $ Just Ro
715+ [vol, "rw"] -> return $ VolumeFrom vol $ Just ReadWrite
716+ [vol, "ro"] -> return $ VolumeFrom vol $ Just ReadOnly
711717 _ -> fail "Could not parse VolumeFrom"
712718 parseJSON _ = fail "VolumeFrom is not a string"
713719