From 3cc57e7fba0e73c8df6251609564a6bba0ae7a70 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 1 Apr 2014 23:33:06 -0400 Subject: add .propellor suffix to managed containers Avoids deleting any containers that we don't manage.. --- Propellor/Property/Docker.hs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'Propellor') 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 -- cgit v1.2.3