mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit to master@31c870e82a48
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
15
vendor/github.com/moby/buildkit/cmd/buildkitd/config/config.go
generated
vendored
15
vendor/github.com/moby/buildkit/cmd/buildkitd/config/config.go
generated
vendored
@ -7,6 +7,7 @@ import (
|
||||
// Config provides containerd configuration data for the server
|
||||
type Config struct {
|
||||
Debug bool `toml:"debug"`
|
||||
Trace bool `toml:"trace"`
|
||||
|
||||
// Root is the path to a directory where buildkit will store persistent data
|
||||
Root string `toml:"root"`
|
||||
@ -47,7 +48,7 @@ type TLSConfig struct {
|
||||
|
||||
type GCConfig struct {
|
||||
GC *bool `toml:"gc"`
|
||||
GCKeepStorage int64 `toml:"gckeepstorage"`
|
||||
GCKeepStorage DiskSpace `toml:"gckeepstorage"`
|
||||
GCPolicy []GCPolicy `toml:"gcpolicy"`
|
||||
}
|
||||
|
||||
@ -114,10 +115,10 @@ type ContainerdConfig struct {
|
||||
}
|
||||
|
||||
type GCPolicy struct {
|
||||
All bool `toml:"all"`
|
||||
KeepBytes int64 `toml:"keepBytes"`
|
||||
KeepDuration int64 `toml:"keepDuration"`
|
||||
Filters []string `toml:"filters"`
|
||||
All bool `toml:"all"`
|
||||
KeepBytes DiskSpace `toml:"keepBytes"`
|
||||
KeepDuration Duration `toml:"keepDuration"`
|
||||
Filters []string `toml:"filters"`
|
||||
}
|
||||
|
||||
type DNSConfig struct {
|
||||
@ -127,6 +128,6 @@ type DNSConfig struct {
|
||||
}
|
||||
|
||||
type HistoryConfig struct {
|
||||
MaxAge int64 `toml:"maxAge"`
|
||||
MaxEntries int64 `toml:"maxEntries"`
|
||||
MaxAge Duration `toml:"maxAge"`
|
||||
MaxEntries int64 `toml:"maxEntries"`
|
||||
}
|
||||
|
87
vendor/github.com/moby/buildkit/cmd/buildkitd/config/gcpolicy.go
generated
vendored
87
vendor/github.com/moby/buildkit/cmd/buildkitd/config/gcpolicy.go
generated
vendored
@ -1,21 +1,86 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/go-units"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Duration struct {
|
||||
time.Duration
|
||||
}
|
||||
|
||||
func (d *Duration) UnmarshalText(textb []byte) error {
|
||||
text := stripQuotes(string(textb))
|
||||
if len(text) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if duration, err := time.ParseDuration(text); err == nil {
|
||||
d.Duration = duration
|
||||
return nil
|
||||
}
|
||||
|
||||
if i, err := strconv.ParseInt(text, 10, 64); err == nil {
|
||||
d.Duration = time.Duration(i) * time.Second
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.Errorf("invalid duration %s", text)
|
||||
}
|
||||
|
||||
var _ encoding.TextUnmarshaler = &Duration{}
|
||||
|
||||
type DiskSpace struct {
|
||||
Bytes int64
|
||||
Percentage int64
|
||||
}
|
||||
|
||||
var _ encoding.TextUnmarshaler = &DiskSpace{}
|
||||
|
||||
func (d *DiskSpace) UnmarshalText(textb []byte) error {
|
||||
text := stripQuotes(string(textb))
|
||||
if len(text) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if text2 := strings.TrimSuffix(text, "%"); len(text2) < len(text) {
|
||||
i, err := strconv.ParseInt(text2, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.Percentage = i
|
||||
return nil
|
||||
}
|
||||
|
||||
if i, err := units.RAMInBytes(text); err == nil {
|
||||
d.Bytes = i
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.Errorf("invalid disk space %s", text)
|
||||
}
|
||||
|
||||
const defaultCap int64 = 2e9 // 2GB
|
||||
|
||||
func DefaultGCPolicy(p string, keep int64) []GCPolicy {
|
||||
if keep == 0 {
|
||||
keep = DetectDefaultGCCap(p)
|
||||
func DefaultGCPolicy(keep DiskSpace) []GCPolicy {
|
||||
if keep == (DiskSpace{}) {
|
||||
keep = DetectDefaultGCCap()
|
||||
}
|
||||
return []GCPolicy{
|
||||
// if build cache uses more than 512MB delete the most easily reproducible data after it has not been used for 2 days
|
||||
{
|
||||
Filters: []string{"type==source.local,type==exec.cachemount,type==source.git.checkout"},
|
||||
KeepDuration: 48 * 3600, // 48h
|
||||
KeepBytes: 512 * 1e6, // 512MB
|
||||
KeepDuration: Duration{Duration: time.Duration(48) * time.Hour}, // 48h
|
||||
KeepBytes: DiskSpace{Bytes: 512 * 1e6}, // 512MB
|
||||
},
|
||||
// remove any data not used for 60 days
|
||||
{
|
||||
KeepDuration: 60 * 24 * 3600, // 60d
|
||||
KeepDuration: Duration{Duration: time.Duration(60) * 24 * time.Hour}, // 60d
|
||||
KeepBytes: keep,
|
||||
},
|
||||
// keep the unshared build cache under cap
|
||||
@ -29,3 +94,13 @@ func DefaultGCPolicy(p string, keep int64) []GCPolicy {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func stripQuotes(s string) string {
|
||||
if len(s) == 0 {
|
||||
return s
|
||||
}
|
||||
if s[0] == '"' && s[len(s)-1] == '"' {
|
||||
return s[1 : len(s)-1]
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
15
vendor/github.com/moby/buildkit/cmd/buildkitd/config/gcpolicy_unix.go
generated
vendored
15
vendor/github.com/moby/buildkit/cmd/buildkitd/config/gcpolicy_unix.go
generated
vendored
@ -7,12 +7,23 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func DetectDefaultGCCap(root string) int64 {
|
||||
func DetectDefaultGCCap() DiskSpace {
|
||||
return DiskSpace{Percentage: 10}
|
||||
}
|
||||
|
||||
func (d DiskSpace) AsBytes(root string) int64 {
|
||||
if d.Bytes != 0 {
|
||||
return d.Bytes
|
||||
}
|
||||
if d.Percentage == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
var st syscall.Statfs_t
|
||||
if err := syscall.Statfs(root, &st); err != nil {
|
||||
return defaultCap
|
||||
}
|
||||
diskSize := int64(st.Bsize) * int64(st.Blocks)
|
||||
avail := diskSize / 10
|
||||
avail := diskSize * d.Percentage / 100
|
||||
return (avail/(1<<30) + 1) * 1e9 // round up
|
||||
}
|
||||
|
8
vendor/github.com/moby/buildkit/cmd/buildkitd/config/gcpolicy_windows.go
generated
vendored
8
vendor/github.com/moby/buildkit/cmd/buildkitd/config/gcpolicy_windows.go
generated
vendored
@ -3,6 +3,10 @@
|
||||
|
||||
package config
|
||||
|
||||
func DetectDefaultGCCap(root string) int64 {
|
||||
return defaultCap
|
||||
func DetectDefaultGCCap() DiskSpace {
|
||||
return DiskSpace{Bytes: defaultCap}
|
||||
}
|
||||
|
||||
func (d DiskSpace) AsBytes(root string) int64 {
|
||||
return d.Bytes
|
||||
}
|
||||
|
Reference in New Issue
Block a user