summaryrefslogtreecommitdiff
path: root/src/Propellor/Types/Container.hs
blob: de74f79ebe227b0b32c2778acaa4281b88e4e33b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{-# LANGUAGE TypeFamilies, FlexibleInstances #-}

module Propellor.Types.Container where

import Propellor.Types.Info

-- | A value that can be bound between the host and a container.
--
-- For example, a Bound Port is a Port on the container that is bound to
-- a Port on the host.
data Bound v = Bound
	{ hostSide :: v
	, containerSide :: v
	}

-- | Create a Bound value, from two different values for the host and
-- container.
--
-- For example, @Port 8080 -<- Port 80@ means that port 8080 on the host
-- is bound to port 80 from the container.
(-<-) :: (hostv ~ v, containerv ~ v) => hostv -> containerv -> Bound v
(-<-) = Bound

-- | Flipped version of -<- with the container value first and host value
-- second.
(->-) :: (containerv ~ v, hostv ~ v) => containerv -> hostv -> Bound v
(->-) = flip (-<-)

-- | Create a Bound value, that is the same on both the host and container.
same :: v -> Bound v
same v = Bound v v

-- | Capabilities of a container.
data ContainerCapability
	= HostnameContained
	-- ^ The container has its own hostname (and domain name)
	-- separate from the system that contains it.
	| FilesystemContained
	-- ^ The container has its own root filesystem, rather than sharing
	-- the root filesystem of the system that contains it.
	deriving (Typeable, Eq, Read, Show)

-- | A [ContainerCapability] can be used as Info.
-- It does not propagate out to the Host.
-- When not in a container, the Info value will be [].
instance IsInfo [ContainerCapability] where
        propagateInfo _ = PropagateInfo False