From 4e4fb9ab7ca13f5148c6d4b08f53f518429530a8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 18 Apr 2014 03:59:06 -0400 Subject: get rid of AttrProperty Now both Property and RevertableProperty can influence Attr on their own. --- Propellor/Property/Docker.hs | 49 +++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'Propellor/Property/Docker.hs') diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index d2555ea5..e05a8dd3 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -25,7 +25,7 @@ import Data.List.Utils -- | Configures docker with an authentication file, so that images can be -- pushed to index.docker.io. configured :: Property -configured = Property "docker configured" go `requires` installed +configured = property "docker configured" go `requires` installed where go = withPrivData DockerAuthentication $ \cfg -> ensureProperty $ "/root/.dockercfg" `File.hasContent` (lines cfg) @@ -64,7 +64,7 @@ docked -> RevertableProperty docked hosts cn = RevertableProperty (go "docked" setup) (go "undocked" teardown) where - go desc a = Property (desc ++ " " ++ cn) $ do + go desc a = property (desc ++ " " ++ cn) $ do hn <- getHostName let cid = ContainerId hn cn ensureProperties [findContainer hosts cid cn $ a cid] @@ -79,7 +79,7 @@ docked hosts cn = RevertableProperty (go "docked" setup) (go "undocked" teardown teardown cid (Container image _runparams) = combineProperties ("undocked " ++ fromContainerId cid) [ stoppedContainer cid - , Property ("cleaned up " ++ fromContainerId cid) $ + , property ("cleaned up " ++ fromContainerId cid) $ liftIO $ report <$> mapM id [ removeContainer cid , removeImage image @@ -96,7 +96,7 @@ findContainer hosts cid cn mk = case findHost hosts (cn2hn cn) of Nothing -> cantfind Just h -> maybe cantfind mk (mkContainer cid h) where - cantfind = containerDesc cid $ Property "" $ do + cantfind = containerDesc cid $ property "" $ do liftIO $ warningMessage $ "missing definition for docker container \"" ++ cn2hn cn return FailedChange @@ -126,9 +126,9 @@ garbageCollected = propertyList "docker garbage collected" , gcimages ] where - gccontainers = Property "docker containers garbage collected" $ + gccontainers = property "docker containers garbage collected" $ liftIO $ report <$> (mapM removeContainer =<< listContainers AllContainers) - gcimages = Property "docker images garbage collected" $ do + gcimages = property "docker images garbage collected" $ do liftIO $ report <$> (mapM removeImage =<< listImages) data Container = Container Image [RunParam] @@ -140,49 +140,49 @@ type RunParam = String type Image = String -- | Set custom dns server for container. -dns :: String -> AttrProperty +dns :: String -> Property dns = runProp "dns" -- | Set container host name. -hostname :: String -> AttrProperty +hostname :: String -> Property hostname = runProp "hostname" -- | Set name for container. (Normally done automatically.) -name :: String -> AttrProperty +name :: String -> Property name = runProp "name" -- | Publish a container's port to the host -- (format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort) -publish :: String -> AttrProperty +publish :: String -> Property publish = runProp "publish" -- | Username or UID for container. -user :: String -> AttrProperty +user :: String -> Property user = runProp "user" -- | Mount a volume -- Create a bind mount with: [host-dir]:[container-dir]:[rw|ro] -- With just a directory, creates a volume in the container. -volume :: String -> AttrProperty +volume :: String -> Property volume = runProp "volume" -- | Mount a volume from the specified container into the current -- container. -volumes_from :: ContainerName -> AttrProperty +volumes_from :: ContainerName -> Property volumes_from cn = genProp "volumes-from" $ \hn -> fromContainerId (ContainerId hn cn) -- | Work dir inside the container. -workdir :: String -> AttrProperty +workdir :: String -> Property workdir = runProp "workdir" -- | Memory limit for container. --Format: , where unit = b, k, m or g -memory :: String -> AttrProperty +memory :: String -> Property memory = runProp "memory" -- | Link with another container on the same host. -link :: ContainerName -> ContainerAlias -> AttrProperty +link :: ContainerName -> ContainerAlias -> Property link linkwith alias = genProp "link" $ \hn -> fromContainerId (ContainerId hn linkwith) ++ ":" ++ alias @@ -230,7 +230,7 @@ containerDesc cid p = p `describe` desc desc = "[" ++ fromContainerId cid ++ "] " ++ propertyDesc p runningContainer :: ContainerId -> Image -> [RunParam] -> Property -runningContainer cid@(ContainerId hn cn) image runps = containerDesc cid $ Property "running" $ do +runningContainer cid@(ContainerId hn cn) image runps = containerDesc cid $ property "running" $ do l <- liftIO $ listContainers RunningContainers if cid `elem` l then do @@ -324,7 +324,7 @@ chain s = case toContainerId s of -- being run. So, retry connections to the client for up to -- 1 minute. provisionContainer :: ContainerId -> Property -provisionContainer cid = containerDesc cid $ Property "provision" $ liftIO $ do +provisionContainer cid = containerDesc cid $ property "provision" $ liftIO $ do let shim = Shim.file (localdir "propellor") (localdir shimdir cid) r <- simpleShClientRetry 60 (namedPipe cid) shim params (go Nothing) when (r /= FailedChange) $ @@ -356,7 +356,7 @@ stopContainer :: ContainerId -> IO Bool stopContainer cid = boolSystem dockercmd [Param "stop", Param $ fromContainerId cid ] stoppedContainer :: ContainerId -> Property -stoppedContainer cid = containerDesc cid $ Property desc $ +stoppedContainer cid = containerDesc cid $ property desc $ ifM (liftIO $ elem cid <$> listContainers RunningContainers) ( liftIO cleanup `after` ensureProperty (boolProperty desc $ stopContainer cid) @@ -405,18 +405,15 @@ listContainers status = listImages :: IO [Image] listImages = lines <$> readProcess dockercmd ["images", "--all", "--quiet"] -runProp :: String -> RunParam -> AttrProperty -runProp field val = AttrProperty prop $ \attr -> +runProp :: String -> RunParam -> Property +runProp field val = pureAttrProperty (param) $ \attr -> attr { _dockerRunParams = _dockerRunParams attr ++ [\_ -> "--"++param] } where param = field++"="++val - prop = Property (param) (return NoChange) -genProp :: String -> (HostName -> RunParam) -> AttrProperty -genProp field mkval = AttrProperty prop $ \attr -> +genProp :: String -> (HostName -> RunParam) -> Property +genProp field mkval = pureAttrProperty field $ \attr -> attr { _dockerRunParams = _dockerRunParams attr ++ [\hn -> "--"++field++"=" ++ mkval hn] } - where - prop = Property field (return NoChange) -- | The ContainerIdent of a container is written to -- /.propellor-ident inside it. This can be checked to see if -- cgit v1.3-2-g0d8e From 9e578aca6b0914443c95f8691fd3ba39522f28fc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 19 Apr 2014 01:28:46 -0400 Subject: rename aka to alias --- Propellor/Attr.hs | 4 ++-- Propellor/Property/Dns.hs | 4 ++-- Propellor/Property/Docker.hs | 4 ++-- config-joey.hs | 26 +++++++++++++------------- debian/changelog | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) (limited to 'Propellor/Property/Docker.hs') diff --git a/Propellor/Attr.hs b/Propellor/Attr.hs index a54d8833..fb94dc34 100644 --- a/Propellor/Attr.hs +++ b/Propellor/Attr.hs @@ -42,8 +42,8 @@ ipv6 addr = pureAttrProperty ("ipv6 " ++ addr) (addDNS $ Address $ IPv6 addr) -- | Indicates another name for the host in the DNS. -aka :: Domain -> Property -aka domain = pureAttrProperty ("aka " ++ domain) +alias :: Domain -> Property +alias domain = pureAttrProperty ("aka " ++ domain) (addDNS $ CNAME $ AbsDomain domain) addDNS :: Record -> SetAttr diff --git a/Propellor/Property/Dns.hs b/Propellor/Property/Dns.hs index 90556d2d..e47d6c32 100644 --- a/Propellor/Property/Dns.hs +++ b/Propellor/Property/Dns.hs @@ -30,7 +30,7 @@ import Data.List -- -- > host "foo.example.com" -- > & ipv4 "192.168.1.1" --- > & aka "mail.exmaple.com" +-- > & alias "mail.exmaple.com" -- -- Will cause that hostmame and its alias to appear in the zone file, -- with the configured IP address. @@ -134,7 +134,7 @@ namedConfFile = "/etc/bind/named.conf.local" -- repository to the SerialNumber. -- -- Handy trick: You don't need to list IPAddrs in the [Record], --- just make some Host sets its `aka` to the root of domain. +-- just make some Host sets its `alias` to the root of domain. mkSOA :: Domain -> SerialNumber -> [Record] -> SOA mkSOA d sn rs = SOA { sDomain = AbsDomain d diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index e05a8dd3..e5b8d64a 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -183,8 +183,8 @@ memory = runProp "memory" -- | Link with another container on the same host. link :: ContainerName -> ContainerAlias -> Property -link linkwith alias = genProp "link" $ \hn -> - fromContainerId (ContainerId hn linkwith) ++ ":" ++ alias +link linkwith calias = genProp "link" $ \hn -> + fromContainerId (ContainerId hn linkwith) ++ ":" ++ calias -- | A short alias for a linked container. -- Each container has its own alias namespace. diff --git a/config-joey.hs b/config-joey.hs index e49a062c..b22f0e07 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -48,18 +48,18 @@ hosts = -- (o) ` & Postfix.satellite & Docker.configured - & aka "shell.olduse.net" + & alias "shell.olduse.net" & JoeySites.oldUseNetShellBox - & aka "openid.kitenet.net" + & alias "openid.kitenet.net" & Docker.docked hosts "openid-provider" `requires` Apt.installed ["ntp"] - & aka "ancient.kitenet.net" + & alias "ancient.kitenet.net" & Docker.docked hosts "ancient-kitenet" -- I'd rather this were on diatom, but it needs unstable. - & aka "kgb.kitenet.net" + & alias "kgb.kitenet.net" & JoeySites.kgbServer & Docker.garbageCollected `period` Daily @@ -101,25 +101,25 @@ hosts = -- (o) ` & Apache.multiSSL & File.ownerGroup "/srv/web" "joey" "joey" - & aka "git.kitenet.net" - & aka "git.joeyh.name" + & alias "git.kitenet.net" + & alias "git.joeyh.name" & JoeySites.gitServer hosts - & aka "downloads.kitenet.net" + & alias "downloads.kitenet.net" & JoeySites.annexWebSite hosts "/srv/git/downloads.git" "downloads.kitenet.net" "840760dc-08f0-11e2-8c61-576b7e66acfd" [("turtle", "ssh://turtle.kitenet.net/~/lib/downloads/")] & JoeySites.annexRsyncServer - & aka "tmp.kitenet.net" + & alias "tmp.kitenet.net" & JoeySites.annexWebSite hosts "/srv/git/joey/tmp.git" "tmp.kitenet.net" "26fd6e38-1226-11e2-a75f-ff007033bdba" [] & JoeySites.twitRss - & aka "nntp.olduse.net" + & alias "nntp.olduse.net" & JoeySites.oldUseNetServer hosts & Dns.primary hosts "olduse.net" @@ -285,11 +285,11 @@ monsters = -- but do want to track their public keys etc. , host "wren.kitenet.net" & ipv4 "80.68.85.49" & ipv6 "2001:41c8:125:49::10" - & aka "kite.kitenet.net" + & alias "kite.kitenet.net" , host "branchable.com" & ipv4 "66.228.46.55" & ipv6 "2600:3c03::f03c:91ff:fedf:c0e5" - & aka "olduse.net" - & aka "www.olduse.net" - & aka "git.olduse.net" + & alias "olduse.net" + & alias "www.olduse.net" + & alias "git.olduse.net" ] diff --git a/debian/changelog b/debian/changelog index 463b1819..136d61b2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,8 +3,8 @@ propellor (0.4.0) UNRELEASED; urgency=medium * Propellor can configure primary DNS servers, including generating zone files, which is done by looking at the properties of hosts in a domain. - * The `cname` property was renamed to `aka` as it does not always generate - CNAME in the DNS. + * The `cname` property was renamed to `alias` as it does not always + generate CNAME in the DNS. * Constructor of Property has changed (use `property` function instead). * All Property combinators now combine together their Attr settings. So Attr settings can be made inside a propertyList, for example. -- cgit v1.3-2-g0d8e