From 1dcaeb6f776eaf401b1dbe68f836ec3d5953bb0c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 30 Mar 2014 16:49:59 -0400 Subject: [PATCH] cute describe operator --- Propellor.hs | 17 +++++++++-------- Property.hs | 4 ++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Propellor.hs b/Propellor.hs index b3c668d..ad838a1 100644 --- a/Propellor.hs +++ b/Propellor.hs @@ -51,8 +51,8 @@ standardSystem suite = propertyList "standard system" , User.sshAccountFor "joey" , Apt.installed ["sudo"] -- nopasswd because no password is set up for joey. - , "/etc/sudoers" `File.containsLine` "joey ALL=(ALL:ALL) NOPASSWD:ALL" - `describe` "sudoer joey" + , "sudoer joey" ==> + "/etc/sudoers" `File.containsLine` "joey ALL=(ALL:ALL) NOPASSWD:ALL" , GitHome.installedFor "joey" -- I use postfix, or no MTA. , Apt.removed ["exim4"] `onChange` Apt.autoRemove @@ -64,12 +64,13 @@ cleanCloudAtCost hostname = propertyList "cloudatcost cleanup" [ User.nuked "user" , Hostname.set hostname , Ssh.uniqueHostKeys - , "/etc/default/grub" `File.containsLine` "GRUB_DISABLE_LINUX_UUID=true" + , "worked around grub/lvm boot bug #743126" ==> + "/etc/default/grub" `File.containsLine` "GRUB_DISABLE_LINUX_UUID=true" `onChange` cmdProperty "update-grub" [] `onChange` cmdProperty "update-initramfs" [Param "-u"] - `describe` "work around grub/lvm boot bug #743126" - , combineProperties - [ File.notPresent "/etc/rc.local" - , File.notPresent "/etc/init.d/S97-setup.sh" - ] `describe` "nuked cloudatcost cruft" + , "nuked cloudatcost cruft" ==> + combineProperties + [ File.notPresent "/etc/rc.local" + , File.notPresent "/etc/init.d/S97-setup.sh" + ] ] diff --git a/Property.hs b/Property.hs index 77a1f50..95a225c 100644 --- a/Property.hs +++ b/Property.hs @@ -89,6 +89,10 @@ x `requires` y = combineProperties [y, x] `describe` propertyDesc x describe :: Property -> Desc -> Property describe p d = p { propertyDesc = d } +(==>) :: Desc -> Property -> Property +(==>) = flip describe +infixl 1 ==> + {- Makes a Property only be performed when a test succeeds. -} check :: IO Bool -> Property -> Property check c property = Property (propertyDesc property) $ ifM c