diff --git a/distroless/private/group.bzl b/distroless/private/group.bzl index e273612..28f2dfd 100644 --- a/distroless/private/group.bzl +++ b/distroless/private/group.bzl @@ -41,7 +41,7 @@ def group(name, groups, **kwargs): stamp = 0, template = [ "#mtree", - "etc/group uid=0 gid=0 mode=0644 time=0 type=file content={content}", + "etc/group uid=0 gid=0 mode=0644 time=0.0 type=file content={content}", "", ], substitutions = { diff --git a/distroless/private/tar.bzl b/distroless/private/tar.bzl index 514461f..408023d 100644 --- a/distroless/private/tar.bzl +++ b/distroless/private/tar.bzl @@ -2,7 +2,12 @@ BSDTAR_TOOLCHAIN = "@aspect_bazel_lib//lib:tar_toolchain_type" -def _mtree_line(dest, type, content = None, uid = "0", gid = "0", time = "1672560000", mode = "0755"): +DEFAULT_GID = "0" +DEFAULT_UID = "0" +DEFAULT_TIME = "0.0" +DEFAULT_MODE = "0755" + +def _mtree_line(dest, type, content = None, uid = DEFAULT_UID, gid = DEFAULT_GID, time = DEFAULT_TIME, mode = DEFAULT_MODE): # mtree expects paths to start with ./ so normalize paths that starts with # `/` or relative path (without / and ./) if not dest.startswith("."): @@ -21,7 +26,7 @@ def _mtree_line(dest, type, content = None, uid = "0", gid = "0", time = "167256 spec.append("content=" + content) return " ".join(spec) -def _add_parents(path, uid = "0", gid = "0", time = "1672560000", mode = "0755"): +def _add_parents(path, uid = DEFAULT_UID, gid = DEFAULT_GID, time = DEFAULT_TIME, mode = DEFAULT_MODE): lines = [] segments = path.split("/") segments.pop() diff --git a/examples/cacerts/BUILD.bazel b/examples/cacerts/BUILD.bazel index 03bdd0d..373d91c 100644 --- a/examples/cacerts/BUILD.bazel +++ b/examples/cacerts/BUILD.bazel @@ -11,14 +11,14 @@ assert_tar_listing( actual = "cacerts", expected = """\ #mtree -./etc time=1672560000.0 mode=755 gid=0 uid=0 type=dir -./etc/ssl time=1672560000.0 mode=755 gid=0 uid=0 type=dir -./etc/ssl/certs time=1672560000.0 mode=755 gid=0 uid=0 type=dir -./etc/ssl/certs/ca-certificates.crt nlink=0 time=1672560000.0 mode=755 gid=0 uid=0 type=file size=200313 cksum=3175436394 sha1digest=01b4ff230afaeeda5cddaf9a002cec9bc9a6d1b4 -./usr time=1672560000.0 mode=755 gid=0 uid=0 type=dir -./usr/share time=1672560000.0 mode=755 gid=0 uid=0 type=dir -./usr/share/doc time=1672560000.0 mode=755 gid=0 uid=0 type=dir -./usr/share/doc/ca-certificates time=1672560000.0 mode=755 gid=0 uid=0 type=dir -./usr/share/doc/ca-certificates/copyright nlink=0 time=1672560000.0 mode=755 gid=0 uid=0 type=file size=18940 cksum=3142022593 sha1digest=4c49e10ddbcfc0f36816df7f9cb503d665621017 +./etc time=0.0 mode=755 gid=0 uid=0 type=dir +./etc/ssl time=0.0 mode=755 gid=0 uid=0 type=dir +./etc/ssl/certs time=0.0 mode=755 gid=0 uid=0 type=dir +./etc/ssl/certs/ca-certificates.crt nlink=0 time=0.0 mode=755 gid=0 uid=0 type=file size=200313 cksum=3175436394 sha1digest=01b4ff230afaeeda5cddaf9a002cec9bc9a6d1b4 +./usr time=0.0 mode=755 gid=0 uid=0 type=dir +./usr/share time=0.0 mode=755 gid=0 uid=0 type=dir +./usr/share/doc time=0.0 mode=755 gid=0 uid=0 type=dir +./usr/share/doc/ca-certificates time=0.0 mode=755 gid=0 uid=0 type=dir +./usr/share/doc/ca-certificates/copyright nlink=0 time=0.0 mode=755 gid=0 uid=0 type=file size=18940 cksum=3142022593 sha1digest=4c49e10ddbcfc0f36816df7f9cb503d665621017 """, ) diff --git a/examples/home/BUILD.bazel b/examples/home/BUILD.bazel index 1919573..4ec14cc 100644 --- a/examples/home/BUILD.bazel +++ b/examples/home/BUILD.bazel @@ -22,8 +22,8 @@ assert_tar_listing( actual = "home", expected = """\ #mtree -./home time=1672560000.0 mode=755 gid=0 uid=0 type=dir -./home/nonroot time=1672560000.0 mode=755 gid=666 uid=666 type=dir -./root time=1672560000.0 mode=755 gid=0 uid=0 type=dir +./home time=0.0 mode=755 gid=0 uid=0 type=dir +./home/nonroot time=0.0 mode=755 gid=666 uid=666 type=dir +./root time=0.0 mode=755 gid=0 uid=0 type=dir """, ) diff --git a/examples/java_keystore/BUILD.bazel b/examples/java_keystore/BUILD.bazel index b7fd0ad..1623d53 100644 --- a/examples/java_keystore/BUILD.bazel +++ b/examples/java_keystore/BUILD.bazel @@ -28,10 +28,10 @@ assert_tar_listing( actual = "java_keystore", expected = """\ #mtree -./etc time=1672560000.0 mode=755 gid=0 uid=0 type=dir -./etc/ssl time=1672560000.0 mode=755 gid=0 uid=0 type=dir -./etc/ssl/certs time=1672560000.0 mode=755 gid=0 uid=0 type=dir -./etc/ssl/certs/java time=1672560000.0 mode=755 gid=0 uid=0 type=dir -./etc/ssl/certs/java/cacerts nlink=0 time=1672560000.0 mode=755 gid=0 uid=0 type=file size=5349 cksum=3752477219 sha1digest=015078faa5537fcabb6c7e73fe2dedf8241b106d +./etc time=0.0 mode=755 gid=0 uid=0 type=dir +./etc/ssl time=0.0 mode=755 gid=0 uid=0 type=dir +./etc/ssl/certs time=0.0 mode=755 gid=0 uid=0 type=dir +./etc/ssl/certs/java time=0.0 mode=755 gid=0 uid=0 type=dir +./etc/ssl/certs/java/cacerts nlink=0 time=0.0 mode=755 gid=0 uid=0 type=file size=5349 cksum=3752477219 sha1digest=015078faa5537fcabb6c7e73fe2dedf8241b106d """, )