propellor spin
This commit is contained in:
parent
77f3961752
commit
5002b5e391
|
@ -8,7 +8,8 @@ propellor (0.8.0) UNRELEASED; urgency=medium
|
|||
to store the privdata using the new storage scheme.
|
||||
|
||||
* Add --edit to edit a privdata value in $EDITOR.
|
||||
* Add --list-fields to list all currently set privdata fields.
|
||||
* Add --list-fields to list all currently set privdata fields, along with
|
||||
the hosts that use them.
|
||||
* Fix randomHostKeys property to run openssh-server's postinst in a
|
||||
non-failing way.
|
||||
* Hostname.sane now cleans up the 127.0.0.1 localhost line in /etc/hosts,
|
||||
|
|
|
@ -127,6 +127,7 @@ Library
|
|||
Utility.Process
|
||||
Utility.SafeCommand
|
||||
Utility.Scheduled
|
||||
Utility.Table
|
||||
Utility.ThreadScheduler
|
||||
Utility.Tmp
|
||||
Utility.UserInfo
|
||||
|
|
|
@ -26,6 +26,7 @@ import Utility.SafeCommand
|
|||
import Utility.Misc
|
||||
import Utility.FileMode
|
||||
import Utility.Env
|
||||
import Utility.Table
|
||||
|
||||
-- | Allows a Property to access the value of a specific PrivDataField,
|
||||
-- for use in a specific Context.
|
||||
|
@ -90,10 +91,17 @@ editPrivData field context = do
|
|||
listPrivDataFields :: IO ()
|
||||
listPrivDataFields = do
|
||||
m <- decryptPrivData
|
||||
putStrLn ("\nAll currently set privdata fields:")
|
||||
mapM_ list $ M.keys m
|
||||
putStrLn "\n"
|
||||
let rows = map mkrow (M.keys m)
|
||||
let table = tableWithHeader header rows
|
||||
putStr $ unlines $ formatTable table
|
||||
where
|
||||
list = putStrLn . ("\t" ++) . shellEscape . show
|
||||
header = ["Field", "Context", "Hosts"]
|
||||
mkrow (field, (Context context)) =
|
||||
[ shellEscape $ show field
|
||||
, shellEscape context
|
||||
, "xxx"
|
||||
]
|
||||
|
||||
setPrivDataTo :: PrivDataField -> Context -> PrivData -> IO ()
|
||||
setPrivDataTo field context value = do
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
{- text based table generation
|
||||
-
|
||||
- Copyright 2014 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- License: BSD-2-clause
|
||||
-}
|
||||
|
||||
module Utility.Table where
|
||||
|
||||
type Table = [[String]]
|
||||
|
||||
-- | A table with a header that is set off with lines under each
|
||||
-- header item.
|
||||
tableWithHeader :: [String] -> [[String]] -> Table
|
||||
tableWithHeader header rows = header : map linesep header : rows
|
||||
where
|
||||
linesep = map (const '-')
|
||||
|
||||
-- | Formats a table to lines, automatically padding rows to the same size.
|
||||
formatTable :: Table -> [String]
|
||||
formatTable table = map (\r -> unwords (map pad (zip r rowsizes))) table
|
||||
where
|
||||
pad (cell, size) = cell ++ take (size - length cell) padding
|
||||
padding = repeat ' '
|
||||
rowsizes = sumrows (map (map length) table)
|
||||
sumrows [] = repeat 0
|
||||
sumrows [r] = r
|
||||
sumrows (r1:r2:rs) = sumrows $ map (uncurry max) (zip r1 r2) : rs
|
Loading…
Reference in New Issue