fix: rewriting tar header fields (#198)

closes #192

Co-authored-by: DL <david.laburthe@external.terega.fr>
This commit is contained in:
dlaburthe 2021-05-21 15:36:44 +02:00 committed by GitHub
parent 6c796e15a5
commit 588c621617
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,6 +19,7 @@ import (
"path/filepath"
"strconv"
"strings"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
@ -297,6 +298,16 @@ func buildDockerImageContextTar(buildContext string) (string, error) {
// update the name to correctly reflect the desired destination when untaring
header.Name = strings.TrimPrefix(strings.Replace(file, buildContext, "", -1), string(filepath.Separator))
// set archive metadata non deterministic
header.Mode = 0
header.Uid = 0
header.Gid = 0
header.Uname = ""
header.Gname = ""
header.ModTime = time.Time{}
header.AccessTime = time.Time{}
header.ChangeTime = time.Time{}
// write the header
if err := tw.WriteHeader(header); err != nil {
return err