on master help sign in
Adds VolumePermissions (and json instances)
08792fdDeni Bertovic
src/Docker/Client/Types.hs+16−10
@@ -202,7 +202,7 @@ data Mount = Mount {
202 , mountSource :: FilePath
202 , mountSource :: FilePath
203 , mountDestination :: FilePath
203 , mountDestination :: FilePath
204 , mountDriver :: Text
204 , mountDriver :: Text
205− , mountMode :: Text -- Note: Improve this?
205+ , mountMode :: Maybe VolumePermission -- apparently this can be null
206 , mountRW :: Bool
206 , mountRW :: Bool
207 , mountPropogation :: Text
207 , mountPropogation :: Text
208 }
208 }
@@ -645,12 +645,18 @@ defaultLogOpts = LogOpts { stdout = True
645 , tail = All
645 , tail = All
646 }
646 }
647
647
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.
648−data VolumePermission = Rw | Ro deriving (Eq, Show, Generic)
650+data VolumePermission = ReadWrite | ReadOnly deriving (Eq, Show, Generic)
649
651
650−-- instance ToJSON VolumePermission where
652+instance ToJSON VolumePermission where
651−-- toJSON = error "TODO"
653+ toJSON ReadWrite = "rw"
654+ toJSON ReadOnly = "ro"
655+
652−-- instance FromJSON VolumePermission where
656+instance FromJSON VolumePermission where
653−-- parseJSON = error "TODO"
657+ parseJSON "rw" = return ReadWrite
658+ parseJSON "ro" = return ReadOnly
659+ parseJSON _ = fail "Failed to parse VolumePermission"
654
660
655-- | Used for marking a directory in the container as "exposed" hence
661-- | Used for marking a directory in the container as "exposed" hence
656-- taking it outside of the COW filesystem and making it mountable
662-- taking it outside of the COW filesystem and making it mountable
@@ -680,8 +686,8 @@ data Volume = Volume { hostSrc :: Text
680instance FromJSON Volume where
686instance FromJSON Volume where
681 parseJSON (JSON.String t) = case T.split (== ':') t of
687 parseJSON (JSON.String t) = case T.split (== ':') t of
682 [src, dest] -> return $ Volume src dest Nothing
688 [src, dest] -> return $ Volume src dest Nothing
683− [src, dest, "rw"] -> return $ Volume src dest $ Just Rw
689+ [src, dest, "rw"] -> return $ Volume src dest $ Just ReadWrite
684− [src, dest, "ro"] -> return $ Volume src dest $ Just Ro
690+ [src, dest, "ro"] -> return $ Volume src dest $ Just ReadOnly
685 _ -> fail "Could not parse Volume"
691 _ -> fail "Could not parse Volume"
686 parseJSON _ = fail "Volume is not a string"
692 parseJSON _ = fail "Volume is not a string"
687
693
@@ -706,8 +712,8 @@ data VolumeFrom = VolumeFrom ContainerName (Maybe VolumePermission) deriving (Eq
706instance FromJSON VolumeFrom where
712instance FromJSON VolumeFrom where
707 parseJSON (JSON.String t) = case T.split (== ':') t of
713 parseJSON (JSON.String t) = case T.split (== ':') t of
708 [vol] -> return $ VolumeFrom vol Nothing
714 [vol] -> return $ VolumeFrom vol Nothing
709− [vol, "rw"] -> return $ VolumeFrom vol $ Just Rw
715+ [vol, "rw"] -> return $ VolumeFrom vol $ Just ReadWrite
710− [vol, "ro"] -> return $ VolumeFrom vol $ Just Ro
716+ [vol, "ro"] -> return $ VolumeFrom vol $ Just ReadOnly
711 _ -> fail "Could not parse VolumeFrom"
717 _ -> fail "Could not parse VolumeFrom"
712 parseJSON _ = fail "VolumeFrom is not a string"
718 parseJSON _ = fail "VolumeFrom is not a string"
713
719