From 7f7249f801653e0bd7fa083ed001bf3c5a3c3900 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 16 Oct 2015 15:31:18 -0400 Subject: add a LinkTarget type to disambiguate parameters of isSymlinkedTo Something about making symlinks is very confusing about which parameter is which. It perhaps doesn't help that isSymlinkedTo has the target second, while ln has it first. Let's use a type to prevent confusion. Also, simplified some properties that now use isSymlinkedTo. Since isSymlinkedTo checks the link target, these properties don't need to check themselves that the link is in place. --- src/Propellor/Property/Nginx.hs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/Propellor/Property/Nginx.hs') diff --git a/src/Propellor/Property/Nginx.hs b/src/Propellor/Property/Nginx.hs index 1bd285c7..c9b4d8fd 100644 --- a/src/Propellor/Property/Nginx.hs +++ b/src/Propellor/Property/Nginx.hs @@ -6,23 +6,17 @@ import Propellor.Base import qualified Propellor.Property.File as File import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.Service as Service -import System.Posix.Files type ConfigFile = [String] siteEnabled :: HostName -> ConfigFile -> RevertableProperty siteEnabled hn cf = enable disable where - enable = check test prop + enable = siteVal hn `File.isSymlinkedTo` siteValRelativeCfg hn `describe` ("nginx site enabled " ++ hn) `requires` siteAvailable hn cf `requires` installed `onChange` reloaded - where - test = not <$> doesFileExist (siteVal hn) - prop = dir `File.isSymlinkedTo` target - target = siteValRelativeCfg hn - dir = siteVal hn disable = trivial $ File.notPresent (siteVal hn) `describe` ("nginx site disable" ++ hn) `requires` installed @@ -40,8 +34,8 @@ siteCfg hn = "/etc/nginx/sites-available/" ++ hn siteVal :: HostName -> FilePath siteVal hn = "/etc/nginx/sites-enabled/" ++ hn -siteValRelativeCfg :: HostName -> FilePath -siteValRelativeCfg hn = "../sites-available/" ++ hn +siteValRelativeCfg :: HostName -> File.LinkTarget +siteValRelativeCfg hn = File.LinkTarget ("../sites-available/" ++ hn) installed :: Property NoInfo installed = Apt.installed ["nginx"] -- cgit v1.2.3