Skip to content

Commit

Permalink
Add fromImageId to obtain images without running docker pull
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbiehl committed Apr 10, 2024
1 parent 75ed7a3 commit 5a249cf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/TestContainers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module TestContainers
-- * Referring to Docker images
M.ToImage,
M.fromTag,
M.fromImageId,
M.fromBuildContext,
M.build,

Expand Down
12 changes: 11 additions & 1 deletion src/TestContainers/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ module TestContainers.Docker
-- * Referring to images
ToImage,
fromTag,
fromImageId,
fromBuildContext,
fromDockerfile,
build,
Expand Down Expand Up @@ -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 <tag>@ to obtain an image id.
--
-- @since 0.1.0.0
fromTag :: ImageTag -> ToImage
Expand All @@ -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)
--
Expand Down
1 change: 1 addition & 0 deletions src/TestContainers/Image.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import TestContainers.Docker as Docker
build,
fromBuildContext,
fromDockerfile,
fromImageId,
fromTag,
)

Expand Down

0 comments on commit 5a249cf

Please sign in to comment.