on master help sign in
Stanardizes volumes/volumesfrom
35ad365Deni Bertovic
src/Docker/Types.hs+17−24
@@ -119,31 +119,24 @@ data LogOpts = LogOpts {
119 , tail :: TailLogOpt
119 , tail :: TailLogOpt
120 } deriving (Eq, Show)
120 } deriving (Eq, Show)
121
121
122−data BindMountMode = Rw | Ro deriving (Eq, Show, Generic)
122+data VolumePermission = Rw | Ro deriving (Eq, Show, Generic)
123
123
124−instance ToJSON BindMountMode
124+instance ToJSON VolumePermission
125−instance FromJSON BindMountMode
125+instance FromJSON VolumePermission
126
126
127−data BindMount = BindMount {
128− hostSrc :: Text
127+data Volume = Volume { hostSrc :: Text
129− , containerDest :: Text
128+ , containerDest :: Text
130− , mountMode :: Maybe BindMountMode
129+ , volumePermission :: Maybe VolumePermission
131− } deriving (Eq, Show)
132−
133−data Volume = Volume {
134− containerName :: Text
135− , volumeMode :: Maybe BindMountMode
136− } deriving (Eq, Show)
130+ } deriving (Eq, Show)
137
131
138−-- BindMount "/tmp" "/tmp2" (Just Rw)
132+type ContainerName = Text
139−-- instance FromJSON BindMount where
140−-- parseJSON (JSON.Object v) = TODO
141
133
134+data VolumeFrom = VolumeFrom ContainerName VolumePermission deriving (Eq, Show)
142
135
143−instance ToJSON BindMount where
136+instance ToJSON Volume where
144− toJSON (BindMount s d mode) = toJSON $ case mode of
137+ toJSON (Volume src dest mode) = toJSON $ case mode of
145− Nothing -> T.concat[s, ":", d]
138+ Nothing -> T.concat[src, ":", dest]
146− Just m -> T.concat[s, ":", d, ":", (T.pack $ show m)]
139+ Just m -> T.concat[src, ":", dest, ":", (T.pack $ show m)]
147
140
148data Link = Link Text (Maybe Text) deriving (Eq, Show)
141data Link = Link Text (Maybe Text) deriving (Eq, Show)
149
142
@@ -186,14 +179,14 @@ newtype UTSMode = UTSMode Text deriving (Eq, Show)
186-- TODO: Add Tmpfs : List of tmpfs (mounts) used for the container
179-- TODO: Add Tmpfs : List of tmpfs (mounts) used for the container
187-- TODO: Add UTSMode : UTS namespace to use for the container
180-- TODO: Add UTSMode : UTS namespace to use for the container
188data HostConfig = HostConfig
181data HostConfig = HostConfig
189− { binds :: [BindMount]
182+ { binds :: [Volume]
190 , containerIDFile :: FilePath
183 , containerIDFile :: FilePath
191 , logConfig :: LogDriverConfig
184 , logConfig :: LogDriverConfig
192 , networkMode :: NetworkMode
185 , networkMode :: NetworkMode
193 , portBindings :: [PortBinding]
186 , portBindings :: [PortBinding]
194 , restartPolicy :: RestartPolicy
187 , restartPolicy :: RestartPolicy
195 , volumeDriver :: Text
188 , volumeDriver :: Text
196− , volumesFrom :: Volume
189+ , volumesFrom :: [VolumeFrom]
197 , capAdd :: [Text]
190 , capAdd :: [Text]
198 , capDrop :: [Text]
191 , capDrop :: [Text]
199 , dns :: [Text]
192 , dns :: [Text]
@@ -238,7 +231,7 @@ data ContainerResources = ContainerResources {
238 , cpuQuota :: Integer
231 , cpuQuota :: Integer
239 , cpusetCpus :: Integer
232 , cpusetCpus :: Integer
240 , cpusetMems :: Text
233 , cpusetMems :: Text
241− , devices :: [BindMount]
234+ , devices :: [Volume]
242 , diskQuota :: Integer
235 , diskQuota :: Integer
243 , kernelMemory :: Integer
236 , kernelMemory :: Integer
244 , memory :: Integer
237 , memory :: Integer
@@ -273,7 +266,7 @@ data ContainerConfig = ContainerConfig {
273 , cmd :: Text
266 , cmd :: Text
274 , argsEscaped :: Bool
267 , argsEscaped :: Bool
275 , image :: Text
268 , image :: Text
276− , volumes :: [BindMount]
269+ , volumes :: [Volume]
277 , workingDir :: FilePath
270 , workingDir :: FilePath
278 , entrypoint :: Text
271 , entrypoint :: Text
279 , networkDisabled :: Bool
272 , networkDisabled :: Bool