summaryrefslogtreecommitdiff
path: root/src/Propellor/PrivData.hs
diff options
context:
space:
mode:
authorJoey Hess2014-12-14 16:14:05 -0400
committerJoey Hess2014-12-14 16:14:05 -0400
commit23399416f1ba89894f65f61b436c2b0f8378e6c5 (patch)
tree161b0d4bcf18cd7fb9bf58a7a7089b868dad2777 /src/Propellor/PrivData.hs
parent71723ca09f369ccf96462cef1e0200e1615677d1 (diff)
broke up big function to describe PrivDataField
Diffstat (limited to 'src/Propellor/PrivData.hs')
-rw-r--r--src/Propellor/PrivData.hs23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/Propellor/PrivData.hs b/src/Propellor/PrivData.hs
index b0228b46..6253e924 100644
--- a/src/Propellor/PrivData.hs
+++ b/src/Propellor/PrivData.hs
@@ -48,30 +48,30 @@ import Utility.Table
-- being used, which is necessary to ensure that the privdata is sent to
-- the remote host by propellor.
withPrivData
- :: IsContext c
- => PrivDataField
+ :: (IsContext c, IsPrivDataSource s)
+ => s
-> c
-> (((PrivData -> Propellor Result) -> Propellor Result) -> Property)
-> Property
-withPrivData field = withPrivData' snd [field]
+withPrivData s = withPrivData' snd [s]
-- Like withPrivData, but here any of a list of PrivDataFields can be used.
withSomePrivData
- :: IsContext c
- => [PrivDataField]
+ :: (IsContext c, IsPrivDataSource s)
+ => [s]
-> c
-> ((((PrivDataField, PrivData) -> Propellor Result) -> Propellor Result) -> Property)
-> Property
withSomePrivData = withPrivData' id
withPrivData'
- :: IsContext c
+ :: (IsContext c, IsPrivDataSource s)
=> ((PrivDataField, PrivData) -> v)
- -> [PrivDataField]
+ -> [s]
-> c
-> (((v -> Propellor Result) -> Propellor Result) -> Property)
-> Property
-withPrivData' feed fieldlist c mkprop = addinfo $ mkprop $ \a ->
+withPrivData' feed srclist c mkprop = addinfo $ mkprop $ \a ->
maybe missing (a . feed) =<< getM get fieldlist
where
get field = do
@@ -82,14 +82,15 @@ withPrivData' feed fieldlist c mkprop = addinfo $ mkprop $ \a ->
Context cname <- mkHostContext hc <$> asks hostName
warningMessage $ "Missing privdata " ++ intercalate " or " fieldnames ++ " (for " ++ cname ++ ")"
liftIO $ putStrLn $ "Fix this by running:"
- liftIO $ forM_ fieldlist $ \f -> do
- putStrLn $ " propellor --set '" ++ show f ++ "' '" ++ cname ++ "'"
- putStrLn $ " < ( " ++ howtoMkPrivDataField f ++ " )"
+ liftIO $ forM_ srclist $ \src -> do
+ putStrLn $ " propellor --set '" ++ show (privDataField src) ++ "' '" ++ cname ++ "'"
+ maybe noop (\d -> putStrLn $ " " ++ d) (describePrivDataSource src)
putStrLn ""
return FailedChange
addinfo p = p { propertyInfo = propertyInfo p <> mempty { _privDataFields = fieldset } }
fieldnames = map show fieldlist
fieldset = S.fromList $ zip fieldlist (repeat hc)
+ fieldlist = map privDataField srclist
hc = asHostContext c
addPrivDataField :: (PrivDataField, HostContext) -> Property