Skip to content

Commit 824efc7

Browse files
authored
fix(mutate): also set timestamps only present in some formats (#1550)
Currently, layerTime only mutates the modification timestamp which is present in all tar formats. When working with layers GNU or PAX header formats, access and change timestamps are also generated/recorded. This breaks functionality like reproducible builds which rely on having control over all variable fields (esp. timestamps) in the layers This commit adds a special case to the layerTime(Layer, Time) function which will also set the additional timestamps if the header is of GNU or PAX format Signed-off-by: Joel Pepper <pepper@bronze-deer.de>
1 parent 061ee6b commit 824efc7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/v1/mutate/mutate.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,13 @@ func layerTime(layer v1.Layer, t time.Time) (v1.Layer, error) {
465465
}
466466

467467
header.ModTime = t
468+
469+
//PAX and GNU Format support additional timestamps in the header
470+
if header.Format == tar.FormatPAX || header.Format == tar.FormatGNU {
471+
header.AccessTime = t
472+
header.ChangeTime = t
473+
}
474+
468475
if err := tarWriter.WriteHeader(header); err != nil {
469476
return nil, fmt.Errorf("writing tar header: %w", err)
470477
}

0 commit comments

Comments
 (0)