propellor

propellor config for hosts.
git clone git://git.ricketyspace.net/propellor.git
Log | Files | Refs | LICENSE

Chroot.hs (1207B)


      1 {-# LANGUAGE DeriveDataTypeable #-}
      2 
      3 module Propellor.Types.Chroot where
      4 
      5 import Propellor.Types
      6 import Propellor.Types.Empty
      7 import Propellor.Types.Info
      8 
      9 import qualified Data.Semigroup as Sem
     10 import qualified Data.Map as M
     11 import Data.Monoid
     12 import Prelude
     13 
     14 data ChrootInfo = ChrootInfo
     15 	{ _chroots :: M.Map FilePath Host
     16 	, _chrootCfg :: ChrootCfg
     17 	}
     18 	deriving (Show, Typeable)
     19 
     20 instance IsInfo ChrootInfo where
     21 	propagateInfo _ = PropagateInfo False
     22 
     23 instance Sem.Semigroup ChrootInfo where
     24 	old <> new = ChrootInfo
     25 		{ _chroots = M.union (_chroots old) (_chroots new)
     26 		, _chrootCfg = _chrootCfg old <> _chrootCfg new
     27 		}
     28 
     29 instance Monoid ChrootInfo where
     30 	mempty = ChrootInfo mempty mempty
     31 	mappend = (Sem.<>)
     32 
     33 instance Empty ChrootInfo where
     34 	isEmpty i = and
     35 		[ isEmpty (_chroots i)
     36 		, isEmpty (_chrootCfg i)
     37 		]
     38 
     39 data ChrootCfg
     40 	= NoChrootCfg
     41 	| SystemdNspawnCfg [(String, Bool)]
     42 	deriving (Show, Eq)
     43 
     44 instance Sem.Semigroup ChrootCfg where
     45 	v <> NoChrootCfg = v
     46 	NoChrootCfg <> v = v
     47 	SystemdNspawnCfg l1 <> SystemdNspawnCfg l2 =
     48 		SystemdNspawnCfg (l1 <> l2)
     49 
     50 instance Monoid ChrootCfg where
     51 	mempty = NoChrootCfg
     52 	mappend = (Sem.<>)
     53 
     54 instance Empty ChrootCfg where
     55 	isEmpty c= c == NoChrootCfg