summaryrefslogtreecommitdiff
path: root/src/Propellor/Types.hs
diff options
context:
space:
mode:
authorJoey Hess2015-01-19 15:09:03 -0400
committerJoey Hess2015-01-19 15:09:03 -0400
commit603e6d340611dc15bca876c6374bf5938b8a3d4e (patch)
tree925f2eeb80d26a3c1f1d3c99acda2906d78f9b8e /src/Propellor/Types.hs
parent04d4d0d6c43dcf7643417bb16927f314b55e42fc (diff)
split out types to improve haddock for Propellor.Types
Diffstat (limited to 'src/Propellor/Types.hs')
-rw-r--r--src/Propellor/Types.hs87
1 files changed, 4 insertions, 83 deletions
diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs
index 728cebc1..e330d5be 100644
--- a/src/Propellor/Types.hs
+++ b/src/Propellor/Types.hs
@@ -3,33 +3,21 @@
module Propellor.Types
( Host(..)
- , Info(..)
, Propellor(..)
, Property(..)
, RevertableProperty(..)
, IsProp(..)
, Desc
- , Result(..)
- , ToResult(..)
- , ActionResult(..)
- , CmdLine(..)
- , PrivDataField(..)
- , PrivData
- , Context(..)
- , anyContext
- , SshKeyType(..)
- , Val(..)
- , fromVal
+ , Info(..)
, RunLog
, EndAction(..)
, module Propellor.Types.OS
, module Propellor.Types.Dns
+ , module Propellor.Types.Result
) where
import Data.Monoid
import Control.Applicative
-import System.Console.ANSI
-import System.Posix.Types
import "mtl" Control.Monad.RWS.Strict
import "MonadCatchIO-transformers" Control.Monad.CatchIO
import qualified Data.Set as S
@@ -41,6 +29,8 @@ import Propellor.Types.Dns
import Propellor.Types.Docker
import Propellor.Types.PrivData
import Propellor.Types.Empty
+import Propellor.Types.Val
+import Propellor.Types.Result
import qualified Propellor.Types.Dns as Dns
-- | Everything Propellor knows about a system: Its hostname,
@@ -126,58 +116,6 @@ instance IsProp RevertableProperty where
type Desc = String
-data Result = NoChange | MadeChange | FailedChange
- deriving (Read, Show, Eq)
-
-instance Monoid Result where
- mempty = NoChange
-
- mappend FailedChange _ = FailedChange
- mappend _ FailedChange = FailedChange
- mappend MadeChange _ = MadeChange
- mappend _ MadeChange = MadeChange
- mappend NoChange NoChange = NoChange
-
-class ToResult t where
- toResult :: t -> Result
-
-instance ToResult Bool where
- toResult False = FailedChange
- toResult True = MadeChange
-
--- | Results of actions, with color.
-class ActionResult a where
- getActionResult :: a -> (String, ColorIntensity, Color)
-
-instance ActionResult Bool where
- getActionResult False = ("failed", Vivid, Red)
- getActionResult True = ("done", Dull, Green)
-
-instance ActionResult Result where
- getActionResult NoChange = ("ok", Dull, Green)
- getActionResult MadeChange = ("done", Vivid, Green)
- getActionResult FailedChange = ("failed", Vivid, Red)
-
-data CmdLine
- = Run HostName
- | Spin [HostName] (Maybe HostName)
- | SimpleRun HostName
- | Set PrivDataField Context
- | Dump PrivDataField Context
- | Edit PrivDataField Context
- | ListFields
- | AddKey String
- | Merge
- | Serialized CmdLine
- | Continue CmdLine
- | Update (Maybe HostName)
- | Relay HostName
- | DockerInit HostName
- | DockerChain HostName String
- | ChrootChain HostName FilePath Bool Bool
- | GitPush Fd Fd
- deriving (Read, Show, Eq)
-
-- | Information about a host.
data Info = Info
{ _os :: Val System
@@ -216,23 +154,6 @@ instance Empty Info where
, isEmpty (_chrootinfo i)
]
-data Val a = Val a | NoVal
- deriving (Eq, Show)
-
-instance Monoid (Val a) where
- mempty = NoVal
- mappend old new = case new of
- NoVal -> old
- _ -> new
-
-instance Empty (Val a) where
- isEmpty NoVal = True
- isEmpty _ = False
-
-fromVal :: Val a -> Maybe a
-fromVal (Val a) = Just a
-fromVal NoVal = Nothing
-
type RunLog = [EndAction]
-- | An action that Propellor runs at the end, after trying to satisfy all