summaryrefslogtreecommitdiff
path: root/src/Propellor/Types.hs
diff options
context:
space:
mode:
authorJoey Hess2014-12-07 17:09:55 -0400
committerJoey Hess2014-12-07 17:09:55 -0400
commit42a0c832483296fb111279fc3512a3dfd44f2089 (patch)
tree328c20c8a34e908806d240ec2dd5a02437c8df6b /src/Propellor/Types.hs
parent5a932c382d4cbe65957eb0d3ebe4a9319d8dfd14 (diff)
Display a warning when ensureProperty is used on a property which has Info and is so prevented from propigating it.
Would much rather a type-based fixed, but this is all I have for now.
Diffstat (limited to 'src/Propellor/Types.hs')
-rw-r--r--src/Propellor/Types.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs
index e00a457d..72e0e7ad 100644
--- a/src/Propellor/Types.hs
+++ b/src/Propellor/Types.hs
@@ -43,6 +43,7 @@ import Propellor.Types.Chroot
import Propellor.Types.Dns
import Propellor.Types.Docker
import Propellor.Types.PrivData
+import Propellor.Types.Empty
-- | Everything Propellor knows about a system: Its hostname,
-- properties and other info.
@@ -188,6 +189,18 @@ instance Monoid Info where
, _chrootinfo = _chrootinfo old <> _chrootinfo new
}
+instance Empty Info where
+ isEmpty i = and
+ [ isEmpty (_os i)
+ , isEmpty (_privDataFields i)
+ , isEmpty (_sshPubKey i)
+ , isEmpty (_aliases i)
+ , isEmpty (_dns i)
+ , isEmpty (_namedconf i)
+ , isEmpty (_dockerinfo i)
+ , isEmpty (_chrootinfo i)
+ ]
+
data Val a = Val a | NoVal
deriving (Eq, Show)
@@ -197,6 +210,10 @@ instance Monoid (Val a) where
NoVal -> old
_ -> new
+instance Empty (Val a) where
+ isEmpty NoVal = True
+ isEmpty _ = False
+
fromVal :: Val a -> Maybe a
fromVal (Val a) = Just a
fromVal NoVal = Nothing