1
0
mirror of https://github.com/drone/drone-cli.git synced 2026-01-24 19:58:01 +01:00
drone-cli/vendor/github.com/drone/drone-runtime/engine/docker/tar.go
2018-10-09 11:18:46 -07:00

26 lines
492 B
Go

package docker
import (
"archive/tar"
"bytes"
"time"
"github.com/drone/drone-runtime/engine"
)
// helper function creates a tarfile that can be uploaded
// into the Docker container.
func createTarfile(file *engine.File, mount *engine.FileMount) []byte {
w := new(bytes.Buffer)
t := tar.NewWriter(w)
h := &tar.Header{
Name: mount.Path,
Mode: mount.Mode,
Size: int64(len(file.Data)),
ModTime: time.Now(),
}
t.WriteHeader(h)
t.Write(file.Data)
return w.Bytes()
}