Docker: volume and publish accept Bound FilePath and Bound Port, respectively. They also continue to accept Strings, for backwards compatability.
This commit is contained in:
parent
c9dc306016
commit
e11c68cf1e
|
@ -21,6 +21,9 @@ propellor (2.5.0) UNRELEASED; urgency=medium
|
||||||
* Firewall: Port was changed to a newtype, and the Port and PortRange
|
* Firewall: Port was changed to a newtype, and the Port and PortRange
|
||||||
constructors of Rules were changed to DPort and DportRange, respectively.
|
constructors of Rules were changed to DPort and DportRange, respectively.
|
||||||
(API change)
|
(API change)
|
||||||
|
* Docker: volume and publish accept Bound FilePath and Bound Port,
|
||||||
|
respectively. They also continue to accept Strings, for backwards
|
||||||
|
compatability.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Thu, 07 May 2015 12:08:34 -0400
|
-- Joey Hess <id@joeyh.name> Thu, 07 May 2015 12:08:34 -0400
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,11 @@ module Propellor.Property.Docker (
|
||||||
-- * Container configuration
|
-- * Container configuration
|
||||||
dns,
|
dns,
|
||||||
hostname,
|
hostname,
|
||||||
|
Publishable,
|
||||||
publish,
|
publish,
|
||||||
expose,
|
expose,
|
||||||
user,
|
user,
|
||||||
|
Mountable,
|
||||||
volume,
|
volume,
|
||||||
volumes_from,
|
volumes_from,
|
||||||
workdir,
|
workdir,
|
||||||
|
@ -43,6 +45,7 @@ module Propellor.Property.Docker (
|
||||||
|
|
||||||
import Propellor hiding (init)
|
import Propellor hiding (init)
|
||||||
import Propellor.Types.Docker
|
import Propellor.Types.Docker
|
||||||
|
import Propellor.Types.Container
|
||||||
import Propellor.Types.CmdLine
|
import Propellor.Types.CmdLine
|
||||||
import qualified Propellor.Property.File as File
|
import qualified Propellor.Property.File as File
|
||||||
import qualified Propellor.Property.Apt as Apt
|
import qualified Propellor.Property.Apt as Apt
|
||||||
|
@ -254,10 +257,19 @@ hostname = runProp "hostname"
|
||||||
name :: String -> Property HasInfo
|
name :: String -> Property HasInfo
|
||||||
name = runProp "name"
|
name = runProp "name"
|
||||||
|
|
||||||
|
class Publishable p where
|
||||||
|
toPublish :: p -> String
|
||||||
|
|
||||||
|
instance Publishable (Bound Port) where
|
||||||
|
toPublish p = show (hostSide p) ++ ":" ++ show (containerSide p)
|
||||||
|
|
||||||
|
-- | string format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort
|
||||||
|
instance Publishable String where
|
||||||
|
toPublish = id
|
||||||
|
|
||||||
-- | Publish a container's port to the host
|
-- | Publish a container's port to the host
|
||||||
-- (format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort)
|
publish :: Publishable p => p -> Property HasInfo
|
||||||
publish :: String -> Property HasInfo
|
publish = runProp "publish" . toPublish
|
||||||
publish = runProp "publish"
|
|
||||||
|
|
||||||
-- | Expose a container's port without publishing it.
|
-- | Expose a container's port without publishing it.
|
||||||
expose :: String -> Property HasInfo
|
expose :: String -> Property HasInfo
|
||||||
|
@ -267,11 +279,21 @@ expose = runProp "expose"
|
||||||
user :: String -> Property HasInfo
|
user :: String -> Property HasInfo
|
||||||
user = runProp "user"
|
user = runProp "user"
|
||||||
|
|
||||||
-- | Mount a volume
|
class Mountable p where
|
||||||
-- Create a bind mount with: [host-dir]:[container-dir]:[rw|ro]
|
toMount :: p -> String
|
||||||
|
|
||||||
|
instance Mountable (Bound FilePath) where
|
||||||
|
toMount p = hostSide p ++ ":" ++ containerSide p
|
||||||
|
|
||||||
|
-- | string format: [host-dir]:[container-dir]:[rw|ro]
|
||||||
|
--
|
||||||
-- With just a directory, creates a volume in the container.
|
-- With just a directory, creates a volume in the container.
|
||||||
volume :: String -> Property HasInfo
|
instance Mountable String where
|
||||||
volume = runProp "volume"
|
toMount = id
|
||||||
|
|
||||||
|
-- | Mount a volume
|
||||||
|
volume :: Mountable v => v -> Property HasInfo
|
||||||
|
volume = runProp "volume" . toMount
|
||||||
|
|
||||||
-- | Mount a volume from the specified container into the current
|
-- | Mount a volume from the specified container into the current
|
||||||
-- container.
|
-- container.
|
||||||
|
|
Loading…
Reference in New Issue