From db4121edeeba2899926333df46308ca0baf45b71 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 26 Feb 2017 16:40:34 -0400 Subject: use val instead of show --- src/Propellor/Property/Apt.hs | 2 +- src/Propellor/Property/Attic.hs | 10 +++++----- src/Propellor/Property/Borg.hs | 10 +++++----- src/Propellor/Property/Ccache.hs | 2 +- src/Propellor/Property/Dns.hs | 12 ++++++------ src/Propellor/Property/Grub.hs | 2 +- src/Propellor/Property/Obnam.hs | 2 +- src/Propellor/Property/SiteSpecific/JoeySites.hs | 6 +++--- src/Propellor/Property/Unbound.hs | 4 ++-- src/Propellor/Types/ConfigurableValue.hs | 11 +++++++++++ 10 files changed, 36 insertions(+), 25 deletions(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs index 9a55c367..4490aa95 100644 --- a/src/Propellor/Property/Apt.hs +++ b/src/Propellor/Property/Apt.hs @@ -452,7 +452,7 @@ suitePinBlock p suite pin = [ "Explanation: This file added by propellor" , "Package: " ++ p , "Pin: release " ++ suitePin suite - , "Pin-Priority: " ++ show pin + , "Pin-Priority: " ++ val pin ] dpkgStatus :: FilePath diff --git a/src/Propellor/Property/Attic.hs b/src/Propellor/Property/Attic.hs index 4415f8c0..3059a04b 100644 --- a/src/Propellor/Property/Attic.hs +++ b/src/Propellor/Property/Attic.hs @@ -131,11 +131,11 @@ backup' dir backupdir crontimes extraargs kp = cronjob -- passed to the `backup` property, they will run attic prune to clean out -- generations not specified here. keepParam :: KeepPolicy -> AtticParam -keepParam (KeepHours n) = "--keep-hourly=" ++ show n -keepParam (KeepDays n) = "--keep-daily=" ++ show n -keepParam (KeepWeeks n) = "--keep-daily=" ++ show n -keepParam (KeepMonths n) = "--keep-monthly=" ++ show n -keepParam (KeepYears n) = "--keep-yearly=" ++ show n +keepParam (KeepHours n) = "--keep-hourly=" ++ val n +keepParam (KeepDays n) = "--keep-daily=" ++ val n +keepParam (KeepWeeks n) = "--keep-daily=" ++ val n +keepParam (KeepMonths n) = "--keep-monthly=" ++ val n +keepParam (KeepYears n) = "--keep-yearly=" ++ val n -- | Policy for backup generations to keep. For example, KeepDays 30 will -- keep the latest backup for each day when a backup was made, and keep the diff --git a/src/Propellor/Property/Borg.hs b/src/Propellor/Property/Borg.hs index 16030562..7ed39794 100644 --- a/src/Propellor/Property/Borg.hs +++ b/src/Propellor/Property/Borg.hs @@ -137,11 +137,11 @@ backup' dir backupdir crontimes extraargs kp = cronjob -- passed to the `backup` property, they will run borg prune to clean out -- generations not specified here. keepParam :: KeepPolicy -> BorgParam -keepParam (KeepHours n) = "--keep-hourly=" ++ show n -keepParam (KeepDays n) = "--keep-daily=" ++ show n -keepParam (KeepWeeks n) = "--keep-daily=" ++ show n -keepParam (KeepMonths n) = "--keep-monthly=" ++ show n -keepParam (KeepYears n) = "--keep-yearly=" ++ show n +keepParam (KeepHours n) = "--keep-hourly=" ++ val n +keepParam (KeepDays n) = "--keep-daily=" ++ val n +keepParam (KeepWeeks n) = "--keep-daily=" ++ val n +keepParam (KeepMonths n) = "--keep-monthly=" ++ val n +keepParam (KeepYears n) = "--keep-yearly=" ++ val n -- | Policy for backup generations to keep. For example, KeepDays 30 will -- keep the latest backup for each day when a backup was made, and keep the diff --git a/src/Propellor/Property/Ccache.hs b/src/Propellor/Property/Ccache.hs index c0b8d539..a2bef117 100644 --- a/src/Propellor/Property/Ccache.hs +++ b/src/Propellor/Property/Ccache.hs @@ -76,7 +76,7 @@ limitToParams NoLimit = [] limitToParams (MaxSize s) = case maxSizeParam s of Just param -> [Right param] Nothing -> [Left $ "unable to parse data size " ++ s] -limitToParams (MaxFiles f) = [Right $ "--max-files=" ++ show f] +limitToParams (MaxFiles f) = [Right $ "--max-files=" ++ val f] limitToParams (l1 :+ l2) = limitToParams l1 <> limitToParams l2 -- | Configures a ccache in /var/cache for a group diff --git a/src/Propellor/Property/Dns.hs b/src/Propellor/Property/Dns.hs index 2e2710a6..3fcffed3 100644 --- a/src/Propellor/Property/Dns.hs +++ b/src/Propellor/Property/Dns.hs @@ -307,17 +307,17 @@ rValue :: Record -> Maybe String rValue (Address (IPv4 addr)) = Just addr rValue (Address (IPv6 addr)) = Just addr rValue (CNAME d) = Just $ dValue d -rValue (MX pri d) = Just $ show pri ++ " " ++ dValue d +rValue (MX pri d) = Just $ val pri ++ " " ++ dValue d rValue (NS d) = Just $ dValue d rValue (SRV priority weight port target) = Just $ unwords - [ show priority - , show weight - , show port + [ val priority + , val weight + , val port , dValue target ] rValue (SSHFP x y s) = Just $ unwords - [ show x - , show y + [ val x + , val y , s ] rValue (INCLUDE f) = Just f diff --git a/src/Propellor/Property/Grub.hs b/src/Propellor/Property/Grub.hs index a03fc5a0..9dd5e8e1 100644 --- a/src/Propellor/Property/Grub.hs +++ b/src/Propellor/Property/Grub.hs @@ -69,7 +69,7 @@ chainPVGrub rootdev bootdev timeout = combineProperties desc $ props & File.dirExists "/boot/grub" & "/boot/grub/menu.lst" `File.hasContent` [ "default 1" - , "timeout " ++ show timeout + , "timeout " ++ val timeout , "" , "title grub-xen shim" , "root (" ++ rootdev ++ ")" diff --git a/src/Propellor/Property/Obnam.hs b/src/Propellor/Property/Obnam.hs index 5bf3ff06..66d3c08d 100644 --- a/src/Propellor/Property/Obnam.hs +++ b/src/Propellor/Property/Obnam.hs @@ -150,7 +150,7 @@ keepParam ps = "--keep=" ++ intercalate "," (map go ps) go (KeepWeeks n) = mk n 'w' go (KeepMonths n) = mk n 'm' go (KeepYears n) = mk n 'y' - mk n c = show n ++ [c] + mk n c = val n ++ [c] isKeepParam :: ObnamParam -> Bool isKeepParam p = "--keep=" `isPrefixOf` p diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index 445bce07..c14d1707 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -314,9 +314,9 @@ apacheSite hn middle = Apache.siteEnabled hn $ apachecfg hn middle apachecfg :: HostName -> Apache.ConfigFile -> Apache.ConfigFile apachecfg hn middle = - [ "" + [ "" , " ServerAdmin grue@joeyh.name" - , " ServerName "++hn++":"++show port + , " ServerName "++hn++":" ++ val port ] ++ middle ++ [ "" @@ -329,7 +329,7 @@ apachecfg hn middle = , "" ] where - port = 80 :: Int + port = Port 80 gitAnnexDistributor :: Property (HasInfo + DebianLike) gitAnnexDistributor = combineProperties "git-annex distributor, including rsync server and signer" $ props diff --git a/src/Propellor/Property/Unbound.hs b/src/Propellor/Property/Unbound.hs index 23a5b30d..9eb8f8c9 100644 --- a/src/Propellor/Property/Unbound.hs +++ b/src/Propellor/Property/Unbound.hs @@ -133,10 +133,10 @@ genAddress dom ttl addr = case addr of IPv6 _ -> genAddress' "AAAA" dom ttl addr genAddress' :: String -> BindDomain -> Maybe Int -> IPAddr -> String -genAddress' recordtype dom ttl addr = dValue dom ++ " " ++ maybe "" (\ttl' -> show ttl' ++ " ") ttl ++ "IN " ++ recordtype ++ " " ++ fromIPAddr addr +genAddress' recordtype dom ttl addr = dValue dom ++ " " ++ maybe "" (\ttl' -> val ttl' ++ " ") ttl ++ "IN " ++ recordtype ++ " " ++ fromIPAddr addr genMX :: BindDomain -> Int -> BindDomain -> String -genMX dom priority dest = dValue dom ++ " " ++ "MX" ++ " " ++ show priority ++ " " ++ dValue dest +genMX dom priority dest = dValue dom ++ " " ++ "MX" ++ " " ++ val priority ++ " " ++ dValue dest genPTR :: BindDomain -> ReverseIP -> String genPTR dom revip = revip ++ ". " ++ "PTR" ++ " " ++ dValue dom diff --git a/src/Propellor/Types/ConfigurableValue.hs b/src/Propellor/Types/ConfigurableValue.hs index 10a608f8..6235bee9 100644 --- a/src/Propellor/Types/ConfigurableValue.hs +++ b/src/Propellor/Types/ConfigurableValue.hs @@ -2,6 +2,8 @@ module Propellor.Types.ConfigurableValue where +import Data.Word + -- | A value that can be used in a configuration file, or otherwise used to -- configure a program. -- @@ -30,3 +32,12 @@ instance ConfigurableValue Float where instance ConfigurableValue Double where val = show + +instance ConfigurableValue Word8 where + val = show + +instance ConfigurableValue Word16 where + val = show + +instance ConfigurableValue Word32 where + val = show -- cgit v1.2.3