diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-10-20 23:37:21 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-10-20 23:37:21 -0400 |
| commit | 0e39d53352b982022747e451676bc6a66e3d9acc (patch) | |
| tree | 37f84bb464b71437d7ff90c571d1f127a8127edb /src | |
| parent | 745f42c1499749345c32736342959584587c9b57 (diff) | |
refactor
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor/PrivData.hs | 4 | ||||
| -rw-r--r-- | src/Propellor/Property/ControlHeir.hs | 4 | ||||
| -rw-r--r-- | src/Propellor/Spin.hs | 4 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/Propellor/PrivData.hs b/src/Propellor/PrivData.hs index 070070f0..aac37d14 100644 --- a/src/Propellor/PrivData.hs +++ b/src/Propellor/PrivData.hs @@ -17,6 +17,7 @@ module Propellor.PrivData ( makePrivDataDir, decryptPrivData, readPrivData, + readPrivDataFile, PrivMap, PrivInfo, forceHostContext, @@ -254,6 +255,9 @@ decryptPrivData = readPrivData <$> gpgDecrypt privDataFile readPrivData :: String -> PrivMap readPrivData = fromMaybe M.empty . readish +readPrivDataFile :: FilePath -> IO PrivMap +readPrivDataFile f = readPrivData <$> readFileStrictAnyEncoding f + makePrivDataDir :: IO () makePrivDataDir = createDirectoryIfMissing False privDataDir diff --git a/src/Propellor/Property/ControlHeir.hs b/src/Propellor/Property/ControlHeir.hs index 9fd2ce43..ce993a02 100644 --- a/src/Propellor/Property/ControlHeir.hs +++ b/src/Propellor/Property/ControlHeir.hs @@ -179,8 +179,8 @@ controllerFor h = infoProperty desc go (mkControllingInfo h <> privinfo) [] getInfo (hostInfo h) go = do - pm <- liftIO $ filterPrivData h . readPrivData - <$> readFileStrictAnyEncoding privDataLocal + pm <- liftIO $ filterPrivData h + <$> readPrivDataFile privDataLocal liftIO $ spin' (Just pm) Nothing (hostName h) h -- Don't know if the spin made a change to -- the remote host or not, but in any case, diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs index 3cdd8c98..0c457705 100644 --- a/src/Propellor/Spin.hs +++ b/src/Propellor/Spin.hs @@ -100,9 +100,9 @@ spin' mprivdata relay target hst = do Nothing | relaying -> do let f = privDataRelay hn - d <- readFileStrictAnyEncoding f + d <- readPrivDataFile f nukeFile f - return (readPrivData d) + return d | otherwise -> filterPrivData hst <$> decryptPrivData Just pd -> pure pd |
