epoch: propagate SOURCE_DATE_EPOCH via ctx

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda
2022-11-30 22:26:32 +09:00
parent 36641eade6
commit dc48349248
7 changed files with 67 additions and 9 deletions

View File

@@ -30,6 +30,7 @@ import (
"time"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/pkg/epoch"
"github.com/containerd/containerd/pkg/userns"
"github.com/containerd/continuity/fs"
)
@@ -80,6 +81,10 @@ func WriteDiff(ctx context.Context, w io.Writer, a, b string, opts ...WriteDiffO
return fmt.Errorf("failed to apply option: %w", err)
}
}
if tm := epoch.FromContext(ctx); tm != nil && options.SourceDateEpoch == nil {
options.SourceDateEpoch = tm
}
if options.writeDiffFunc == nil {
options.writeDiffFunc = writeDiffNaive
}