diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-03-24 15:42:47 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-03-24 15:42:47 -0400 |
| commit | f5e7596cb9183158644fdd2df9996871dc0a8efa (patch) | |
| tree | 4878b3ea899cd5fe66e847f163c94b9b3e64bbcf /src | |
| parent | ab2204fc868f8f0e9fbc57a4b0b75996a38d934d (diff) | |
converted Propellor.Info
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor/Info.hs | 19 | ||||
| -rw-r--r-- | src/Propellor/Types.hs | 5 |
2 files changed, 14 insertions, 10 deletions
diff --git a/src/Propellor/Info.hs b/src/Propellor/Info.hs index 7eb7d4a8..4827ba8a 100644 --- a/src/Propellor/Info.hs +++ b/src/Propellor/Info.hs @@ -13,11 +13,14 @@ import Data.Monoid import Control.Applicative import Prelude -pureInfoProperty :: (IsInfo v) => Desc -> v -> Property HasInfo +pureInfoProperty :: (IsInfo v) => Desc -> v -> Property (HasInfo + UnixLike) pureInfoProperty desc v = pureInfoProperty' desc (addInfo mempty v) -pureInfoProperty' :: Desc -> Info -> Property HasInfo -pureInfoProperty' desc i = infoProperty ("has " ++ desc) (return NoChange) i mempty +pureInfoProperty' :: Desc -> Info -> Property (HasInfo + UnixLike) +pureInfoProperty' desc i = addInfoProperty p i + where + p :: Property UnixLike + p = mkProperty ("has " ++ desc) (return NoChange) -- | Gets a value from the host's Info. askInfo :: (IsInfo v) => Propellor v @@ -27,7 +30,7 @@ askInfo = asks (getInfo . hostInfo) -- -- This only provides info for other Properties, so they can act -- conditionally on the os. -os :: System -> Property HasInfo +os :: System -> Property (HasInfo + UnixLike) os system = pureInfoProperty ("Operating " ++ show system) (InfoVal system) -- Gets the operating system of a host, if it has been specified. @@ -43,11 +46,11 @@ getOS = fromInfoVal <$> askInfo -- When propellor --spin is used to deploy a host, it checks -- if the host's IP Property matches the DNS. If the DNS is missing or -- out of date, the host will instead be contacted directly by IP address. -ipv4 :: String -> Property HasInfo +ipv4 :: String -> Property (HasInfo + UnixLike) ipv4 = addDNS . Address . IPv4 -- | Indicate that a host has an AAAA record in the DNS. -ipv6 :: String -> Property HasInfo +ipv6 :: String -> Property (HasInfo + UnixLike) ipv6 = addDNS . Address . IPv6 -- | Indicates another name for the host in the DNS. @@ -56,14 +59,14 @@ ipv6 = addDNS . Address . IPv6 -- to use their address, rather than using a CNAME. This avoids various -- problems with CNAMEs, and also means that when multiple hosts have the -- same alias, a DNS round-robin is automatically set up. -alias :: Domain -> Property HasInfo +alias :: Domain -> Property (HasInfo + UnixLike) alias d = pureInfoProperty' ("alias " ++ d) $ mempty `addInfo` toAliasesInfo [d] -- A CNAME is added here, but the DNS setup code converts it to an -- IP address when that makes sense. `addInfo` (toDnsInfo $ S.singleton $ CNAME $ AbsDomain d) -addDNS :: Record -> Property HasInfo +addDNS :: Record -> Property (HasInfo + UnixLike) addDNS r = pureInfoProperty (rdesc r) (toDnsInfo (S.singleton r)) where rdesc (CNAME d) = unwords ["alias", ddesc d] diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs index 25269969..49ba9220 100644 --- a/src/Propellor/Types.hs +++ b/src/Propellor/Types.hs @@ -149,11 +149,12 @@ mkProperty d a = Property sing d a mempty mempty -- -- The new Property will include HasInfo in its metatypes. addInfoProperty - :: (metatypes' ~ (+) HasInfo metatypes, SingI metatypes') + :: (Sing metatypes' ~ (+) HasInfo metatypes, SingI metatypes') => Property metatypes -> Info -> Property (Sing metatypes') -addInfoProperty (Property metatypes d a i c) newi = Property sing d a (i <> newi) c +addInfoProperty (Property metatypes d a oldi c) newi = + Property sing d a (oldi <> newi) c {- |
