diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-05-22 14:16:16 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-05-22 14:16:16 -0400 |
| commit | 53f2646c4520e5c788d4b60dae63049222737acc (patch) | |
| tree | 39086348281d342fa87de9211950a94d34753894 /src/Propellor/Property/Docker.hs | |
| parent | da4636eb28e86d6909e2160c2ba7a00dcafc7ca9 (diff) | |
| parent | e661aad6c493e31b6bd8109ca3d5c90bec28626a (diff) | |
Merge branch 'joeyconfig'
Conflicts:
privdata.joey/privdata.gpg
Diffstat (limited to 'src/Propellor/Property/Docker.hs')
| -rw-r--r-- | src/Propellor/Property/Docker.hs | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/Propellor/Property/Docker.hs b/src/Propellor/Property/Docker.hs index 745b5622..fdc312ce 100644 --- a/src/Propellor/Property/Docker.hs +++ b/src/Propellor/Property/Docker.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleContexts, TypeSynonymInstances, FlexibleInstances #-} -- | Docker support for propellor -- @@ -18,7 +18,8 @@ module Propellor.Property.Docker ( tweaked, Image, ContainerName, - Container(..), + Container, + HasImage(..), -- * Container configuration dns, hostname, @@ -79,10 +80,16 @@ configured = prop `requires` installed type ContainerName = String -- | A docker container. -data Container = Container - { containerImage :: Image - , containerHost :: Host - } +data Container = Container Image Host + +class HasImage a where + getImageName :: a -> Image + +instance HasImage Image where + getImageName = id + +instance HasImage Container where + getImageName (Container i _) = i instance PropAccum Container where (Container i h) & p = Container i (h & p) @@ -142,19 +149,21 @@ docked ctr@(Container _ h) = ] -- | Build the image from a directory containing a Dockerfile. -imageBuilt :: FilePath -> Image -> Property NoInfo -imageBuilt directory image = describe built msg +imageBuilt :: HasImage c => FilePath -> c -> Property NoInfo +imageBuilt directory ctr = describe built msg where msg = "docker image " ++ image ++ " built from " ++ directory built = Cmd.cmdProperty' dockercmd ["build", "--tag", image, "./"] workDir workDir p = p { cwd = Just directory } + image = getImageName ctr -- | Pull the image from the standard Docker Hub registry. -imagePulled :: Image -> Property NoInfo -imagePulled image = describe pulled msg +imagePulled :: HasImage c => c -> Property NoInfo +imagePulled ctr = describe pulled msg where msg = "docker image " ++ image ++ " pulled" pulled = Cmd.cmdProperty dockercmd ["pull", image] + image = getImageName ctr propigateContainerInfo :: (IsProp (Property i)) => Container -> Property i -> Property HasInfo propigateContainerInfo ctr@(Container _ h) p = propigateContainer ctr p' |
