3
0
Fork 0
forked from mirrors/nixpkgs

dockerTools.buildLayeredImage: fix created=now

This commit is contained in:
Jos van Bakel 2020-07-09 09:34:18 +02:00
parent 0dbc88331f
commit 66737168a4
No known key found for this signature in database
GPG key ID: 37589FBAE4DA2BC3
3 changed files with 23 additions and 4 deletions

View file

@ -90,13 +90,22 @@ import ./make-test-python.nix ({ pkgs, ... }: {
with subtest("Ensure Docker images can use an unstable date"):
docker.succeed(
"docker load --input='${examples.bash}'"
"docker load --input='${examples.unstableDate}'"
)
assert unix_time_second1 not in docker.succeed(
"docker inspect ${examples.unstableDate.imageName} "
+ "| ${pkgs.jq}/bin/jq -r .[].Created"
)
with subtest("Ensure Layered Docker images can use an unstable date"):
docker.succeed(
"docker load --input='${examples.unstableDateLayered}'"
)
assert unix_time_second1 not in docker.succeed(
"docker inspect ${examples.unstableDateLayered.imageName} "
+ "| ${pkgs.jq}/bin/jq -r .[].Created"
)
with subtest("Ensure Layered Docker images work"):
docker.succeed(
"docker load --input='${examples.layered-image}'",

View file

@ -354,4 +354,14 @@ rec {
Env = [ "USER=root" ];
};
};
# 20. Ensure that setting created to now results in a date which
# isn't the epoch + 1 for layered images.
unstableDateLayered = pkgs.dockerTools.buildLayeredImage {
name = "unstable-date-layered";
tag = "latest";
contents = [ pkgs.coreutils ];
created = "now";
};
}

View file

@ -41,7 +41,7 @@ import pathlib
import tarfile
import itertools
import threading
from datetime import datetime
from datetime import datetime, timezone
from collections import namedtuple
@ -242,7 +242,7 @@ def main():
conf = json.load(f)
created = (
datetime.now(tz=datetime.timezone.utc)
datetime.now(tz=timezone.utc)
if conf["created"] == "now"
else datetime.fromisoformat(conf["created"])
)
@ -280,7 +280,7 @@ def main():
},
"history": [
{
"created": conf["created"],
"created": datetime.isoformat(created),
"comment": f"store paths: {layer.paths}"
}
for layer in layers