archive: add WithSourceDateEpoch() for whiteouts

This makes diff archives to be reproducible.

The value is expected to be passed from CLI applications via the $SOUCE_DATE_EPOCH env var.

See https://reproducible-builds.org/docs/source-date-epoch/
for the $SOURCE_DATE_EPOCH specification.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda
2022-10-08 08:45:03 +09:00
parent 6fcfcf3a89
commit 70fbedc217
13 changed files with 390 additions and 104 deletions

View File

@@ -31,6 +31,7 @@ import (
"github.com/containerd/containerd/diff"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/pkg/epoch"
"github.com/containerd/containerd/pkg/progress"
"github.com/containerd/containerd/rootfs"
"github.com/containerd/containerd/snapshots"
@@ -142,6 +143,14 @@ var diffCommand = cli.Command{
diff.WithLabels(labels),
}
ep, err := epoch.SourceDateEpoch()
if err != nil {
return err
}
if ep != nil {
opts = append(opts, diff.WithSourceDateEpoch(ep))
}
if idB == "" {
desc, err = rootfs.CreateDiff(ctx, idA, snapshotter, client.DiffService(), opts...)
if err != nil {