summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2014-11-21 18:55:33 -0400
committerJoey Hess2014-11-21 18:55:33 -0400
commit6c92f1034f980718cef54cab58a1bcfdbc485f5d (patch)
tree3a2bacdc7d3433b6326c01e9acf3f9d2101e04b3
parent04ea987075b869ea70cf55a193af7f5604ff0561 (diff)
split out info types
-rw-r--r--propellor.cabal4
-rw-r--r--src/Propellor/Property/Chroot.hs1
-rw-r--r--src/Propellor/Property/Docker.hs3
-rw-r--r--src/Propellor/Types.hs39
-rw-r--r--src/Propellor/Types/Chroot.hs15
-rw-r--r--src/Propellor/Types/Docker.hs24
6 files changed, 49 insertions, 37 deletions
diff --git a/propellor.cabal b/propellor.cabal
index e40b6e64..645e5fa1 100644
--- a/propellor.cabal
+++ b/propellor.cabal
@@ -113,8 +113,10 @@ Library
Propellor.Engine
Propellor.Exception
Propellor.Types
- Propellor.Types.OS
+ Propellor.Types.Chroot
+ Propellor.Types.Docker
Propellor.Types.Dns
+ Propellor.Types.OS
Propellor.Types.PrivData
Other-Modules:
Propellor.Git
diff --git a/src/Propellor/Property/Chroot.hs b/src/Propellor/Property/Chroot.hs
index 7246e7eb..c3b14a8e 100644
--- a/src/Propellor/Property/Chroot.hs
+++ b/src/Propellor/Property/Chroot.hs
@@ -10,6 +10,7 @@ module Propellor.Property.Chroot (
) where
import Propellor
+import Propellor.Types.Chroot
import qualified Propellor.Property.Debootstrap as Debootstrap
import qualified Propellor.Property.Systemd.Core as Systemd
import qualified Propellor.Shim as Shim
diff --git a/src/Propellor/Property/Docker.hs b/src/Propellor/Property/Docker.hs
index 5cf60ff9..460bc3ec 100644
--- a/src/Propellor/Property/Docker.hs
+++ b/src/Propellor/Property/Docker.hs
@@ -39,6 +39,7 @@ module Propellor.Property.Docker (
) where
import Propellor hiding (init)
+import Propellor.Types.Docker
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Apt as Apt
import qualified Propellor.Shim as Shim
@@ -523,7 +524,7 @@ genProp :: String -> (HostName -> RunParam) -> Property
genProp field mkval = pureInfoProperty field $ dockerInfo $
mempty { _dockerRunParams = [DockerRunParam (\hn -> "--"++field++"=" ++ mkval hn)] }
-dockerInfo :: DockerInfo -> Info
+dockerInfo :: DockerInfo Host -> Info
dockerInfo i = mempty { _dockerinfo = i }
-- | The ContainerIdent of a container is written to
diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs
index a6c5aafa..e7d63547 100644
--- a/src/Propellor/Types.hs
+++ b/src/Propellor/Types.hs
@@ -23,9 +23,6 @@ module Propellor.Types
, SshKeyType(..)
, Val(..)
, fromVal
- , DockerInfo(..)
- , DockerRunParam(..)
- , ChrootInfo(..)
, module Propellor.Types.OS
, module Propellor.Types.Dns
) where
@@ -37,11 +34,12 @@ import System.Posix.Types
import "mtl" Control.Monad.Reader
import "MonadCatchIO-transformers" Control.Monad.CatchIO
import qualified Data.Set as S
-import qualified Data.Map as M
import qualified Propellor.Types.Dns as Dns
import Propellor.Types.OS
+import Propellor.Types.Chroot
import Propellor.Types.Dns
+import Propellor.Types.Docker
import Propellor.Types.PrivData
-- | Everything Propellor knows about a system: Its hostname,
@@ -167,8 +165,8 @@ data Info = Info
, _aliases :: S.Set HostName
, _dns :: S.Set Dns.Record
, _namedconf :: Dns.NamedConfMap
- , _dockerinfo :: DockerInfo
- , _chrootinfo :: ChrootInfo
+ , _dockerinfo :: DockerInfo Host
+ , _chrootinfo :: ChrootInfo Host
}
deriving (Show)
@@ -197,32 +195,3 @@ instance Monoid (Val a) where
fromVal :: Val a -> Maybe a
fromVal (Val a) = Just a
fromVal NoVal = Nothing
-
-data DockerInfo = DockerInfo
- { _dockerRunParams :: [DockerRunParam]
- , _dockerContainers :: M.Map String Host
- }
- deriving (Show)
-
-instance Monoid DockerInfo where
- mempty = DockerInfo mempty mempty
- mappend old new = DockerInfo
- { _dockerRunParams = _dockerRunParams old <> _dockerRunParams new
- , _dockerContainers = M.union (_dockerContainers old) (_dockerContainers new)
- }
-
-newtype DockerRunParam = DockerRunParam (HostName -> String)
-
-instance Show DockerRunParam where
- show (DockerRunParam a) = a ""
-
-data ChrootInfo = ChrootInfo
- { _chroots :: M.Map FilePath Host
- }
- deriving (Show)
-
-instance Monoid ChrootInfo where
- mempty = ChrootInfo mempty
- mappend old new = ChrootInfo
- { _chroots = M.union (_chroots old) (_chroots new)
- }
diff --git a/src/Propellor/Types/Chroot.hs b/src/Propellor/Types/Chroot.hs
new file mode 100644
index 00000000..d4dd6eae
--- /dev/null
+++ b/src/Propellor/Types/Chroot.hs
@@ -0,0 +1,15 @@
+module Propellor.Types.Chroot where
+
+import Data.Monoid
+import qualified Data.Map as M
+
+data ChrootInfo h = ChrootInfo
+ { _chroots :: M.Map FilePath h
+ }
+ deriving (Show)
+
+instance Monoid (ChrootInfo h) where
+ mempty = ChrootInfo mempty
+ mappend old new = ChrootInfo
+ { _chroots = M.union (_chroots old) (_chroots new)
+ }
diff --git a/src/Propellor/Types/Docker.hs b/src/Propellor/Types/Docker.hs
new file mode 100644
index 00000000..42a65923
--- /dev/null
+++ b/src/Propellor/Types/Docker.hs
@@ -0,0 +1,24 @@
+module Propellor.Types.Docker where
+
+import Propellor.Types.OS
+
+import Data.Monoid
+import qualified Data.Map as M
+
+data DockerInfo h = DockerInfo
+ { _dockerRunParams :: [DockerRunParam]
+ , _dockerContainers :: M.Map String h
+ }
+ deriving (Show)
+
+instance Monoid (DockerInfo h) where
+ mempty = DockerInfo mempty mempty
+ mappend old new = DockerInfo
+ { _dockerRunParams = _dockerRunParams old <> _dockerRunParams new
+ , _dockerContainers = M.union (_dockerContainers old) (_dockerContainers new)
+ }
+
+newtype DockerRunParam = DockerRunParam (HostName -> String)
+
+instance Show DockerRunParam where
+ show (DockerRunParam a) = a ""