From 5a249cfe5e8dec9671dc089e6eb1798cd24546be Mon Sep 17 00:00:00 2001 From: Alex Biehl Date: Wed, 10 Apr 2024 10:55:33 +0200 Subject: [PATCH] Add fromImageId to obtain images without running docker pull --- src/TestContainers.hs | 1 + src/TestContainers/Docker.hs | 12 +++++++++++- src/TestContainers/Image.hs | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/TestContainers.hs b/src/TestContainers.hs index b2f7838..519b44e 100644 --- a/src/TestContainers.hs +++ b/src/TestContainers.hs @@ -10,6 +10,7 @@ module TestContainers -- * Referring to Docker images M.ToImage, M.fromTag, + M.fromImageId, M.fromBuildContext, M.build, diff --git a/src/TestContainers/Docker.hs b/src/TestContainers/Docker.hs index acdf716..85a69a5 100644 --- a/src/TestContainers/Docker.hs +++ b/src/TestContainers/Docker.hs @@ -65,6 +65,7 @@ module TestContainers.Docker -- * Referring to images ToImage, fromTag, + fromImageId, fromBuildContext, fromDockerfile, build, @@ -746,7 +747,7 @@ defaultToImage action = { runToImage = action } --- | Get an `Image` from a tag. +-- | Get an `Image` from a tag. This runs @docker pull --quiet @ to obtain an image id. -- -- @since 0.1.0.0 fromTag :: ImageTag -> ToImage @@ -758,6 +759,15 @@ fromTag tag = defaultToImage $ do { tag = strip (pack output) } +-- | Get an `Image` from an image id. This doesn't run @docker pull@ or any other Docker command +-- on construction. +-- +-- @since x.x.x.x +fromImageId :: Text -> ToImage +fromImageId imageId = + defaultToImage $ + pure Image {tag = imageId} + -- | Build the image from a build path and an optional path to the -- Dockerfile (default is Dockerfile) -- diff --git a/src/TestContainers/Image.hs b/src/TestContainers/Image.hs index a369135..a2308cb 100644 --- a/src/TestContainers/Image.hs +++ b/src/TestContainers/Image.hs @@ -16,6 +16,7 @@ import TestContainers.Docker as Docker build, fromBuildContext, fromDockerfile, + fromImageId, fromTag, )