diff options
| author | Joey Hess <joey@kitenet.net> | 2014-04-12 14:14:20 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-04-12 14:14:20 -0400 |
| commit | 9e9d0f1d410f806b546abed6055b25ac81f7042e (patch) | |
| tree | 5a13b54820988c87f3567f90a1c5280763fc885e /Propellor | |
| parent | 61ed9ef26c275ee8466e3d86b0a9b5ae275e3d4e (diff) | |
| parent | b3af5e44d0683033043511fefa3c5fc0ca2a4073 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'Propellor')
| -rw-r--r-- | Propellor/Exception.hs | 6 | ||||
| -rw-r--r-- | Propellor/PrivData.hs | 3 | ||||
| -rw-r--r-- | Propellor/Property.hs | 1 | ||||
| -rw-r--r-- | Propellor/Property/Scheduled.hs | 2 |
4 files changed, 9 insertions, 3 deletions
diff --git a/Propellor/Exception.hs b/Propellor/Exception.hs index bd9212a8..f6fd15f1 100644 --- a/Propellor/Exception.hs +++ b/Propellor/Exception.hs @@ -4,13 +4,15 @@ module Propellor.Exception where import qualified "MonadCatchIO-transformers" Control.Monad.CatchIO as M import Control.Exception -import Control.Applicative import Propellor.Types +import Propellor.Message -- | Catches IO exceptions and returns FailedChange. catchPropellor :: Propellor Result -> Propellor Result -catchPropellor a = either (\_ -> FailedChange) id <$> tryPropellor a +catchPropellor a = either err return =<< tryPropellor a + where + err e = warningMessage (show e) >> return FailedChange tryPropellor :: Propellor a -> Propellor (Either IOException a) tryPropellor = M.try diff --git a/Propellor/PrivData.hs b/Propellor/PrivData.hs index 5adc9e94..c7af1aac 100644 --- a/Propellor/PrivData.hs +++ b/Propellor/PrivData.hs @@ -22,6 +22,9 @@ import Utility.Tmp import Utility.SafeCommand import Utility.Misc +-- | When the specified PrivDataField is available on the host Propellor +-- is provisioning, it provies the data to the action. Otherwise, it prints +-- a message to help the user make the necessary private data available. withPrivData :: PrivDataField -> (String -> Propellor Result) -> Propellor Result withPrivData field a = maybe missing a =<< liftIO (getPrivData field) where diff --git a/Propellor/Property.hs b/Propellor/Property.hs index 3a3c1cb1..83e19a73 100644 --- a/Propellor/Property.hs +++ b/Propellor/Property.hs @@ -105,6 +105,7 @@ host :: HostName -> Host host hn = Host [] (\_ -> newAttr hn) -- | Adds a property to a Host +-- -- Can add Properties, RevertableProperties, and AttrProperties (&) :: IsProp p => Host -> p -> Host (Host ps as) & p = Host (ps ++ [toProp p]) (getAttr p . as) diff --git a/Propellor/Property/Scheduled.hs b/Propellor/Property/Scheduled.hs index 8341765e..769a3931 100644 --- a/Propellor/Property/Scheduled.hs +++ b/Propellor/Property/Scheduled.hs @@ -61,7 +61,7 @@ setLastChecked time desc = do readLastChecked :: IO (M.Map Desc LocalTime) readLastChecked = fromMaybe M.empty <$> catchDefaultIO Nothing go where - go = readish <$> readFile lastCheckedFile + go = readish <$> readFileStrict lastCheckedFile writeLastChecked :: M.Map Desc LocalTime -> IO () writeLastChecked = writeFile lastCheckedFile . show |
