propellor/Propellor/Types/Attr.hs

37 lines
841 B
Haskell
Raw Normal View History

2014-04-11 01:09:20 +00:00
module Propellor.Types.Attr where
import qualified Data.Set as S
-- | The attributes of a host. For example, its hostname.
data Attr = Attr
{ _hostname :: HostName
, _cnames :: S.Set Domain
2014-04-11 03:20:12 +00:00
, _dockerImage :: Maybe String
, _dockerRunParams :: [HostName -> String]
2014-04-11 01:09:20 +00:00
}
2014-04-11 03:20:12 +00:00
instance Eq Attr where
x == y = and
[ _hostname x == _hostname y
, _cnames x == _cnames y
, _dockerImage x == _dockerImage y
, let simpl v = map (\a -> a "") (_dockerRunParams v)
in simpl x == simpl y
]
2014-04-11 01:09:20 +00:00
2014-04-11 04:36:33 +00:00
instance Show Attr where
show a = unlines
[ "hostname " ++ _hostname a
, "cnames " ++ show (_cnames a)
, "docker image " ++ show (_dockerImage a)
2014-04-11 04:40:32 +00:00
, "docker run params " ++ show (map (\mk -> mk "") (_dockerRunParams a))
2014-04-11 04:36:33 +00:00
]
2014-04-11 01:09:20 +00:00
newAttr :: HostName -> Attr
2014-04-11 03:20:12 +00:00
newAttr hn = Attr hn S.empty Nothing []
2014-04-11 01:09:20 +00:00
type HostName = String
type Domain = String