epoch: propagate SOURCE_DATE_EPOCH via ctx
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
@@ -20,7 +20,9 @@ import (
|
||||
gocontext "context"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/pkg/epoch"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -42,6 +44,12 @@ func AppContext(context *cli.Context) (gocontext.Context, gocontext.CancelFunc)
|
||||
} else {
|
||||
ctx, cancel = gocontext.WithCancel(ctx)
|
||||
}
|
||||
if tm, err := epoch.SourceDateEpoch(); err != nil {
|
||||
log.L.WithError(err).Warn("Failed to read SOURCE_DATE_EPOCH")
|
||||
} else if tm != nil {
|
||||
log.L.Debugf("Using SOURCE_DATE_EPOCH: %v", tm)
|
||||
ctx = epoch.WithSourceDateEpoch(ctx, tm)
|
||||
}
|
||||
return ctx, cancel
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ 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,14 +141,7 @@ var diffCommand = cli.Command{
|
||||
diff.WithReference(context.String("ref")),
|
||||
diff.WithLabels(labels),
|
||||
}
|
||||
|
||||
ep, err := epoch.SourceDateEpoch()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ep != nil {
|
||||
opts = append(opts, diff.WithSourceDateEpoch(ep))
|
||||
}
|
||||
// SOURCE_DATE_EPOCH is propagated via the ctx, so no need to specify diff.WithSourceDateEpoch here
|
||||
|
||||
if idB == "" {
|
||||
desc, err = rootfs.CreateDiff(ctx, idA, snapshotter, client.DiffService(), opts...)
|
||||
|
||||
Reference in New Issue
Block a user