diff options
| author | Joey Hess <joey@kitenet.net> | 2014-07-09 22:12:23 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-07-09 22:12:23 -0400 |
| commit | 0c5e16184f795a329ee9592f6c7bf94ec4312d87 (patch) | |
| tree | ac7c846019ac37018cd0446a760b791ab42367ae /src/Propellor/PrivData.hs | |
| parent | 40f64416def7d2a522cc7e3a111593eea8e57134 (diff) | |
| parent | 54d2888a9616cf5005422b34446797f0357b0098 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/PrivData.hs')
| -rw-r--r-- | src/Propellor/PrivData.hs | 16 |
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 |
