summaryrefslogtreecommitdiff
path: root/src/Propellor/PrivData.hs
diff options
context:
space:
mode:
authorJoey Hess2014-07-07 03:42:35 -0400
committerJoey Hess2014-07-07 03:42:35 -0400
commite53faff843a34fd3a4655cb4ee6c570f2072d73e (patch)
tree484f28d47b7fe27a53459fd3ec2178edf04ca98e /src/Propellor/PrivData.hs
parentc2a113ace8ae72f2abeae8e92123bdd9a2063f9c (diff)
propellor spin
Diffstat (limited to 'src/Propellor/PrivData.hs')
-rw-r--r--src/Propellor/PrivData.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Propellor/PrivData.hs b/src/Propellor/PrivData.hs
index c6e41b45..f85ded15 100644
--- a/src/Propellor/PrivData.hs
+++ b/src/Propellor/PrivData.hs
@@ -109,20 +109,24 @@ editPrivData field context = do
listPrivDataFields :: [Host] -> IO ()
listPrivDataFields hosts = do
m <- decryptPrivData
- putStrLn "\n"
- let usedby = M.unionsWith (++) $ map mkhostmap hosts
- let rows = map (mkrow usedby) (M.keys m)
- let table = tableWithHeader header rows
- putStr $ unlines $ formatTable table
+ showtable "Currently set data:" $
+ map mkrow (M.keys m)
+ showtable "Data that would be used if set:" $
+ map mkrow (M.keys $ M.difference wantedmap m)
where
header = ["Field", "Context", "Used by"]
- mkrow usedby k@(field, (Context context)) =
+ mkrow k@(field, (Context context)) =
[ shellEscape $ show field
, shellEscape context
, intercalate ", " $ sort $ fromMaybe [] $ M.lookup k usedby
]
mkhostmap host = M.fromList $ map (\k -> (k, [hostName host])) $
S.toList $ _privDataFields $ hostInfo host
+ usedby = M.unionsWith (++) $ map mkhostmap hosts
+ wantedmap = M.fromList $ zip (M.keys usedby) (repeat "")
+ showtable desc rows = do
+ putStrLn $ "\n" ++ desc
+ putStr $ unlines $ formatTable $ tableWithHeader header rows
setPrivDataTo :: PrivDataField -> Context -> PrivData -> IO ()
setPrivDataTo field context value = do