Merge pull request #139892 from hercules-ci/dockerTools-test-pullImage
dockerTools: test pullImage
This commit is contained in:
commit
286c71a230
@ -119,7 +119,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
|
||||
with subtest("The pullImage tool works"):
|
||||
docker.succeed(
|
||||
"docker load --input='${examples.nixFromDockerHub}'",
|
||||
"docker load --input='${examples.testNixFromDockerHub}'",
|
||||
"docker run --rm nix:2.2.1 nix-store --version",
|
||||
"docker rmi nix:2.2.1",
|
||||
)
|
||||
|
@ -95,6 +95,15 @@ rec {
|
||||
finalImageTag = "2.2.1";
|
||||
finalImageName = "nix";
|
||||
};
|
||||
# Same example, but re-fetches every time the fetcher implementation changes.
|
||||
# NOTE: Only use this for testing, or you'd be wasting a lot of time, network and space.
|
||||
testNixFromDockerHub = pkgs.invalidateFetcherByDrvHash pullImage {
|
||||
imageName = "nixos/nix";
|
||||
imageDigest = "sha256:85299d86263a3059cf19f419f9d286cc9f06d3c13146a8ebbb21b3437f598357";
|
||||
sha256 = "19fw0n3wmddahzr20mhdqv6jkjn1kanh6n2mrr08ai53dr8ph5n7";
|
||||
finalImageTag = "2.2.1";
|
||||
finalImageName = "nix";
|
||||
};
|
||||
|
||||
# 5. example of multiple contents, emacs and vi happily coexisting
|
||||
editors = buildImage {
|
||||
|
@ -618,7 +618,15 @@ with pkgs;
|
||||
drvPath = (f args).drvPath;
|
||||
# It's safe to discard the context, because we don't access the path.
|
||||
salt = builtins.unsafeDiscardStringContext (lib.substring 0 12 (baseNameOf drvPath));
|
||||
in f (args // { name = "${args.name or "source"}-salted-${salt}"; });
|
||||
# New derivation incorporating the original drv hash in the name
|
||||
salted = f (args // { name = "${args.name or "source"}-salted-${salt}"; });
|
||||
# Make sure we did change the derivation. If the fetcher ignores `name`,
|
||||
# `invalidateFetcherByDrvHash` doesn't work.
|
||||
checked =
|
||||
if salted.drvPath == drvPath
|
||||
then throw "invalidateFetcherByDrvHash: Adding the derivation hash to the fixed-output derivation name had no effect. Make sure the fetcher's name argument ends up in the derivation name. Otherwise, the fetcher will not be re-run when its implementation changes. This is important for testing."
|
||||
else salted;
|
||||
in checked;
|
||||
|
||||
lazydocker = callPackage ../tools/misc/lazydocker { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user