summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2014-04-01 23:33:06 -0400
committerJoey Hess2014-04-01 23:33:06 -0400
commit3cc57e7fba0e73c8df6251609564a6bba0ae7a70 (patch)
tree6db458ed04e23707a6bf0b7ccfd44bb3770bea2d
parentb6ef135aa73219a84959e41e36258b04a63b1a9e (diff)
add .propellor suffix to managed containers
Avoids deleting any containers that we don't manage..
-rw-r--r--Propellor/Property/Docker.hs19
1 files changed, 14 insertions, 5 deletions
diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs
index 95486ae6..7189b988 100644
--- a/Propellor/Property/Docker.hs
+++ b/Propellor/Property/Docker.hs
@@ -23,6 +23,7 @@ import Utility.Path
import Control.Concurrent.Async
import System.Posix.Directory
+import Data.List
-- | Configures docker with an authentication file, so that images can be
-- pushed to index.docker.io.
@@ -177,13 +178,21 @@ ident2id :: ContainerIdent -> ContainerId
ident2id (ContainerIdent _ hn cn _) = ContainerId hn cn
toContainerId :: String -> Maybe ContainerId
-toContainerId s = case separate (== '.') s of
- (cn, hn)
- | null hn || null cn -> Nothing
- | otherwise -> Just $ ContainerId hn cn
+toContainerId s
+ | myContainerSuffix `isSuffixOf` s = case separate (== '.') (desuffix s) of
+ (cn, hn)
+ | null hn || null cn -> Nothing
+ | otherwise -> Just $ ContainerId hn cn
+ | otherwise = Nothing
+ where
+ desuffix = reverse . drop len . reverse
+ len = length myContainerSuffix
fromContainerId :: ContainerId -> String
-fromContainerId (ContainerId hn cn) = cn++"."++hn
+fromContainerId (ContainerId hn cn) = cn++"."++hn++myContainerSuffix
+
+myContainerSuffix :: String
+myContainerSuffix = ".propellor"
containerFrom :: Image -> [Containerized Property] -> Container
containerFrom = Container