on master help sign in
Stanardizes volumes/volumesfrom

No reason to have different naming and make things more confusing just because those are the names used internally within the docker daemon.

commit35ad36521e068ad8d333023fcf84dbb04b5ed21f authorDeni Bertovic <deni@denibertovic.com> dateFri 4 Mar 2016, 18:12 (11 years ago) parent2bf4a5c
1 file changed+17−24
src/Docker/Types.hs+17−24
src/Docker/Types.hs+17−24
@@ -119,31 +119,24 @@ data LogOpts = LogOpts {
119119 , tail :: TailLogOpt
120120 } deriving (Eq, Show)
121121
122−data BindMountMode = Rw | Ro deriving (Eq, Show, Generic)
122+data VolumePermission = Rw | Ro deriving (Eq, Show, Generic)
123123
124−instance ToJSON BindMountMode
125−instance FromJSON BindMountMode
124+instance ToJSON VolumePermission
125+instance FromJSON VolumePermission
126126
127−data BindMount = BindMount {
128− hostSrc :: Text
129− , containerDest :: Text
130− , mountMode :: Maybe BindMountMode
131− } deriving (Eq, Show)
132−
133−data Volume = Volume {
134− containerName :: Text
135− , volumeMode :: Maybe BindMountMode
136− } deriving (Eq, Show)
127+data Volume = Volume { hostSrc :: Text
128+ , containerDest :: Text
129+ , volumePermission :: Maybe VolumePermission
130+ } deriving (Eq, Show)
137131
138−-- BindMount "/tmp" "/tmp2" (Just Rw)
139−-- instance FromJSON BindMount where
140−-- parseJSON (JSON.Object v) = TODO
132+type ContainerName = Text
141133
134+data VolumeFrom = VolumeFrom ContainerName VolumePermission deriving (Eq, Show)
142135
143−instance ToJSON BindMount where
144− toJSON (BindMount s d mode) = toJSON $ case mode of
145− Nothing -> T.concat[s, ":", d]
146− Just m -> T.concat[s, ":", d, ":", (T.pack $ show m)]
136+instance ToJSON Volume where
137+ toJSON (Volume src dest mode) = toJSON $ case mode of
138+ Nothing -> T.concat[src, ":", dest]
139+ Just m -> T.concat[src, ":", dest, ":", (T.pack $ show m)]
147140
148141data Link = Link Text (Maybe Text) deriving (Eq, Show)
149142
@@ -186,14 +179,14 @@ newtype UTSMode = UTSMode Text deriving (Eq, Show)
186179-- TODO: Add Tmpfs : List of tmpfs (mounts) used for the container
187180-- TODO: Add UTSMode : UTS namespace to use for the container
188181data HostConfig = HostConfig
189− { binds :: [BindMount]
182+ { binds :: [Volume]
190183 , containerIDFile :: FilePath
191184 , logConfig :: LogDriverConfig
192185 , networkMode :: NetworkMode
193186 , portBindings :: [PortBinding]
194187 , restartPolicy :: RestartPolicy
195188 , volumeDriver :: Text
196− , volumesFrom :: Volume
189+ , volumesFrom :: [VolumeFrom]
197190 , capAdd :: [Text]
198191 , capDrop :: [Text]
199192 , dns :: [Text]
@@ -238,7 +231,7 @@ data ContainerResources = ContainerResources {
238231 , cpuQuota :: Integer
239232 , cpusetCpus :: Integer
240233 , cpusetMems :: Text
241− , devices :: [BindMount]
234+ , devices :: [Volume]
242235 , diskQuota :: Integer
243236 , kernelMemory :: Integer
244237 , memory :: Integer
@@ -273,7 +266,7 @@ data ContainerConfig = ContainerConfig {
273266 , cmd :: Text
274267 , argsEscaped :: Bool
275268 , image :: Text
276− , volumes :: [BindMount]
269+ , volumes :: [Volume]
277270 , workingDir :: FilePath
278271 , entrypoint :: Text
279272 , networkDisabled :: Bool