Documentation
¶
Overview ¶
Package archive writes reproducible tar.gz archives: for a given build of sealift, the same entries always give the same bytes.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteTarGz ¶
WriteTarGz writes a gzip-compressed tar holding root/ and every entry below it, sorted by name. Timestamps are the Unix epoch, owners are 0, files get mode 0644 and the root directory 0755. Entries open one at a time.
Example ¶
package main
import (
"archive/tar"
"bytes"
"compress/gzip"
"fmt"
"io"
"strings"
"github.com/MorganKryze/sealift/archive"
)
func main() {
key := "import-secret"
entries := []archive.Entry{{
Name: "signature.key",
Size: int64(len(key)),
Open: func() (io.ReadCloser, error) { return io.NopCloser(strings.NewReader(key)), nil },
}}
var buf bytes.Buffer
if err := archive.WriteTarGz(&buf, "out", entries); err != nil {
panic(err)
}
gz, _ := gzip.NewReader(&buf)
tr := tar.NewReader(gz)
for h, err := tr.Next(); err == nil; h, err = tr.Next() {
fmt.Println(h.Name)
}
}
Output: out/ out/signature.key
Types ¶
Click to show internal directories.
Click to hide internal directories.