summaryrefslogtreecommitdiff
path: root/Propellor/Property
diff options
context:
space:
mode:
authorJoey Hess2014-04-01 13:04:24 -0400
committerJoey Hess2014-04-01 13:04:24 -0400
commit2d4a0f760b00977aa9f2d00e4bcae6a71bb1fc1e (patch)
treea7bf1d320ba5ea9d95846a45dc775e5d69f9dc1c /Propellor/Property
parent1d180d6ae55b94b704e0731f57daa678833395fd (diff)
fix bug in containerid parsing
Diffstat (limited to 'Propellor/Property')
-rw-r--r--Propellor/Property/Docker.hs20
1 files changed, 10 insertions, 10 deletions
diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs
index 68f623e0..b6980bbd 100644
--- a/Propellor/Property/Docker.hs
+++ b/Propellor/Property/Docker.hs
@@ -49,7 +49,7 @@ type ContainerName = String
-- | A container is identified by its name, and the host
-- on which it's deployed.
data ContainerId = ContainerId HostName ContainerName
- deriving (Read, Show, Eq)
+ deriving (Eq)
toContainerId :: String -> Maybe ContainerId
toContainerId s = case separate (== '.') s of
@@ -99,8 +99,8 @@ hasContainer hn cn findcontainer =
desc = "docker container " ++ fromContainerId cid
ensureContainer :: ContainerId -> Image -> [Containerized Property] -> IO Result
-ensureContainer cid image containerprops = do
- l <- listContainers Running
+ensureContainer cid@(ContainerId hn cn) image containerprops = do
+ l <- listContainers RunningContainers
if cid `elem` l
then do
runningident <- getrunningident
@@ -112,11 +112,11 @@ ensureContainer cid image containerprops = do
removeContainer cid
go oldimage
else do
- whenM (elem cid <$> listContainers Stopped) $
+ whenM (elem cid <$> listContainers AllContainers) $
removeContainer cid
go image
where
- ident = ContainerIdent image cid runps
+ ident = ContainerIdent image hn cn runps
-- Start the simplesh server that will be used by propellor
-- to run commands in the container. An interactive shell
@@ -172,7 +172,7 @@ provisionContainer cid = do
-- | Two containers with the same ContainerIdent were started from
-- the same base image (possibly a different version though), and
-- with the same RunParams.
-data ContainerIdent = ContainerIdent Image ContainerId [RunParam]
+data ContainerIdent = ContainerIdent Image HostName ContainerName [RunParam]
deriving (Read, Show, Eq)
-- | The ContainerIdent of a container is written to
@@ -201,17 +201,17 @@ commitContainer cid = catchMaybeIO $
takeWhile (/= '\n')
<$> readProcess dockercmd ["commit", fromContainerId cid]
-data ContainerStatus = Running | Stopped
+data ContainerFilter = RunningContainers | AllContainers
deriving (Eq)
-- | Only lists propellor managed containers.
-listContainers :: ContainerStatus -> IO [ContainerId]
+listContainers :: ContainerFilter -> IO [ContainerId]
listContainers status =
- catMaybes . map readish . catMaybes . map (lastMaybe . words) . lines
+ catMaybes . map toContainerId . catMaybes . map (lastMaybe . words) . lines
<$> readProcess dockercmd ps
where
ps
- | status == Stopped = baseps ++ ["--all"]
+ | status == AllContainers = baseps ++ ["--all"]
| otherwise = baseps
baseps = ["ps", "--no-trunc"]