mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit to v0.16.0-rc1
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
55
vendor/github.com/moby/buildkit/client/llb/exec.go
generated
vendored
55
vendor/github.com/moby/buildkit/client/llb/exec.go
generated
vendored
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/moby/buildkit/solver/pb"
|
||||
"github.com/moby/buildkit/util/system"
|
||||
@ -290,7 +291,7 @@ func (e *ExecOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
|
||||
if len(e.secrets) > 0 {
|
||||
addCap(&e.constraints, pb.CapExecMountSecret)
|
||||
for _, s := range e.secrets {
|
||||
if s.IsEnv {
|
||||
if s.Env != nil {
|
||||
addCap(&e.constraints, pb.CapExecSecretEnv)
|
||||
break
|
||||
}
|
||||
@ -388,15 +389,17 @@ func (e *ExecOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
|
||||
}
|
||||
|
||||
for _, s := range e.secrets {
|
||||
if s.IsEnv {
|
||||
if s.Env != nil {
|
||||
peo.Secretenv = append(peo.Secretenv, &pb.SecretEnv{
|
||||
ID: s.ID,
|
||||
Name: s.Target,
|
||||
Name: *s.Env,
|
||||
Optional: s.Optional,
|
||||
})
|
||||
} else {
|
||||
}
|
||||
if s.Target != nil {
|
||||
pm := &pb.Mount{
|
||||
Dest: s.Target,
|
||||
Input: pb.Empty,
|
||||
Dest: *s.Target,
|
||||
MountType: pb.MountType_SECRET,
|
||||
SecretOpt: &pb.SecretOpt{
|
||||
ID: s.ID,
|
||||
@ -412,6 +415,7 @@ func (e *ExecOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
|
||||
|
||||
for _, s := range e.ssh {
|
||||
pm := &pb.Mount{
|
||||
Input: pb.Empty,
|
||||
Dest: s.Target,
|
||||
MountType: pb.MountType_SSH,
|
||||
SSHOpt: &pb.SSHOpt{
|
||||
@ -678,7 +682,19 @@ type SSHInfo struct {
|
||||
// AddSecret is a RunOption that adds a secret to the exec.
|
||||
func AddSecret(dest string, opts ...SecretOption) RunOption {
|
||||
return runOptionFunc(func(ei *ExecInfo) {
|
||||
s := &SecretInfo{ID: dest, Target: dest, Mode: 0400}
|
||||
s := &SecretInfo{ID: dest, Target: &dest, Mode: 0400}
|
||||
for _, opt := range opts {
|
||||
opt.SetSecretOption(s)
|
||||
}
|
||||
ei.Secrets = append(ei.Secrets, *s)
|
||||
})
|
||||
}
|
||||
|
||||
// AddSecretWithDest is a RunOption that adds a secret to the exec
|
||||
// with an optional destination.
|
||||
func AddSecretWithDest(src string, dest *string, opts ...SecretOption) RunOption {
|
||||
return runOptionFunc(func(ei *ExecInfo) {
|
||||
s := &SecretInfo{ID: src, Target: dest, Mode: 0400}
|
||||
for _, opt := range opts {
|
||||
opt.SetSecretOption(s)
|
||||
}
|
||||
@ -697,13 +713,15 @@ func (fn secretOptionFunc) SetSecretOption(si *SecretInfo) {
|
||||
}
|
||||
|
||||
type SecretInfo struct {
|
||||
ID string
|
||||
Target string
|
||||
ID string
|
||||
// Target optionally specifies the target for the secret mount
|
||||
Target *string
|
||||
// Env optionally names the environment variable for the secret
|
||||
Env *string
|
||||
Mode int
|
||||
UID int
|
||||
GID int
|
||||
Optional bool
|
||||
IsEnv bool
|
||||
}
|
||||
|
||||
var SecretOptional = secretOptionFunc(func(si *SecretInfo) {
|
||||
@ -719,7 +737,24 @@ func SecretID(id string) SecretOption {
|
||||
// SecretAsEnv defines if the secret should be added as an environment variable
|
||||
func SecretAsEnv(v bool) SecretOption {
|
||||
return secretOptionFunc(func(si *SecretInfo) {
|
||||
si.IsEnv = v
|
||||
if !v {
|
||||
si.Env = nil
|
||||
return
|
||||
}
|
||||
if si.Target == nil {
|
||||
return
|
||||
}
|
||||
target := strings.Clone(*si.Target)
|
||||
si.Env = &target
|
||||
si.Target = nil
|
||||
})
|
||||
}
|
||||
|
||||
// SecretAsEnvName defines if the secret should be added as an environment variable
|
||||
// with the specified name
|
||||
func SecretAsEnvName(v string) SecretOption {
|
||||
return secretOptionFunc(func(si *SecretInfo) {
|
||||
si.Env = &v
|
||||
})
|
||||
}
|
||||
|
||||
|
31
vendor/github.com/moby/buildkit/errdefs/errdefs.go
generated
vendored
31
vendor/github.com/moby/buildkit/errdefs/errdefs.go
generated
vendored
@ -1,31 +0,0 @@
|
||||
package errdefs
|
||||
|
||||
import "errors"
|
||||
|
||||
type internalErr struct {
|
||||
error
|
||||
}
|
||||
|
||||
func (internalErr) System() {}
|
||||
|
||||
func (err internalErr) Unwrap() error {
|
||||
return err.error
|
||||
}
|
||||
|
||||
type system interface {
|
||||
System()
|
||||
}
|
||||
|
||||
var _ system = internalErr{}
|
||||
|
||||
func Internal(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return internalErr{err}
|
||||
}
|
||||
|
||||
func IsInternal(err error) bool {
|
||||
var s system
|
||||
return errors.As(err, &s)
|
||||
}
|
59
vendor/github.com/moby/buildkit/errdefs/internal.go
generated
vendored
Normal file
59
vendor/github.com/moby/buildkit/errdefs/internal.go
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
package errdefs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
type internalErr struct {
|
||||
error
|
||||
}
|
||||
|
||||
func (internalErr) System() {}
|
||||
|
||||
func (err internalErr) Unwrap() error {
|
||||
return err.error
|
||||
}
|
||||
|
||||
type system interface {
|
||||
System()
|
||||
}
|
||||
|
||||
var _ system = internalErr{}
|
||||
|
||||
func Internal(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return internalErr{err}
|
||||
}
|
||||
|
||||
func IsInternal(err error) bool {
|
||||
var s system
|
||||
if errors.As(err, &s) {
|
||||
return true
|
||||
}
|
||||
|
||||
var errno syscall.Errno
|
||||
if errors.As(err, &errno) {
|
||||
if _, ok := isInternalSyscall(errno); ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsResourceExhausted(err error) bool {
|
||||
var errno syscall.Errno
|
||||
if errors.As(err, &errno) {
|
||||
if v, ok := isInternalSyscall(errno); ok && v {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isInternalSyscall(err syscall.Errno) (bool, bool) {
|
||||
v, ok := syscallErrors()[err]
|
||||
return v, ok
|
||||
}
|
23
vendor/github.com/moby/buildkit/errdefs/internal_linux.go
generated
vendored
Normal file
23
vendor/github.com/moby/buildkit/errdefs/internal_linux.go
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package errdefs
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// syscallErrors returns a map of syscall errors that are considered internal.
|
||||
// value is true if the error is of type resource exhaustion, false otherwise.
|
||||
func syscallErrors() map[syscall.Errno]bool {
|
||||
return map[syscall.Errno]bool{
|
||||
unix.EIO: false, // I/O error
|
||||
unix.ENOMEM: true, // Out of memory
|
||||
unix.EFAULT: false, // Bad address
|
||||
unix.ENOSPC: true, // No space left on device
|
||||
unix.ENOTRECOVERABLE: false, // State not recoverable
|
||||
unix.EHWPOISON: false, // Memory page has hardware error
|
||||
}
|
||||
}
|
10
vendor/github.com/moby/buildkit/errdefs/internal_nolinux.go
generated
vendored
Normal file
10
vendor/github.com/moby/buildkit/errdefs/internal_nolinux.go
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
//go:build !linux
|
||||
// +build !linux
|
||||
|
||||
package errdefs
|
||||
|
||||
import "syscall"
|
||||
|
||||
func syscallErrors() map[syscall.Errno]bool {
|
||||
return nil
|
||||
}
|
89
vendor/github.com/moby/buildkit/frontend/dockerfile/linter/linter.go
generated
vendored
89
vendor/github.com/moby/buildkit/frontend/dockerfile/linter/linter.go
generated
vendored
@ -10,42 +10,61 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Warn LintWarnFunc
|
||||
SkipRules []string
|
||||
SkipAll bool
|
||||
ReturnAsError bool
|
||||
ExperimentalAll bool
|
||||
ExperimentalRules []string
|
||||
ReturnAsError bool
|
||||
SkipAll bool
|
||||
SkipRules []string
|
||||
Warn LintWarnFunc
|
||||
}
|
||||
|
||||
type Linter struct {
|
||||
SkippedRules map[string]struct{}
|
||||
CalledRules []string
|
||||
SkipAll bool
|
||||
ReturnAsError bool
|
||||
Warn LintWarnFunc
|
||||
CalledRules []string
|
||||
ExperimentalAll bool
|
||||
ExperimentalRules map[string]struct{}
|
||||
ReturnAsError bool
|
||||
SkipAll bool
|
||||
SkippedRules map[string]struct{}
|
||||
Warn LintWarnFunc
|
||||
}
|
||||
|
||||
func New(config *Config) *Linter {
|
||||
toret := &Linter{
|
||||
SkippedRules: map[string]struct{}{},
|
||||
CalledRules: []string{},
|
||||
Warn: config.Warn,
|
||||
SkippedRules: map[string]struct{}{},
|
||||
ExperimentalRules: map[string]struct{}{},
|
||||
CalledRules: []string{},
|
||||
Warn: config.Warn,
|
||||
}
|
||||
toret.SkipAll = config.SkipAll
|
||||
toret.ExperimentalAll = config.ExperimentalAll
|
||||
toret.ReturnAsError = config.ReturnAsError
|
||||
for _, rule := range config.SkipRules {
|
||||
toret.SkippedRules[rule] = struct{}{}
|
||||
}
|
||||
for _, rule := range config.ExperimentalRules {
|
||||
toret.ExperimentalRules[rule] = struct{}{}
|
||||
}
|
||||
return toret
|
||||
}
|
||||
|
||||
func (lc *Linter) Run(rule LinterRuleI, location []parser.Range, txt ...string) {
|
||||
if lc == nil || lc.Warn == nil || lc.SkipAll || rule.IsDeprecated() {
|
||||
if lc == nil || lc.Warn == nil || rule.IsDeprecated() {
|
||||
return
|
||||
}
|
||||
|
||||
rulename := rule.RuleName()
|
||||
if _, ok := lc.SkippedRules[rulename]; ok {
|
||||
return
|
||||
if rule.IsExperimental() {
|
||||
_, experimentalOk := lc.ExperimentalRules[rulename]
|
||||
if !(lc.ExperimentalAll || experimentalOk) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
_, skipOk := lc.SkippedRules[rulename]
|
||||
if lc.SkipAll || skipOk {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
lc.CalledRules = append(lc.CalledRules, rulename)
|
||||
rule.Run(lc.Warn, location, txt...)
|
||||
}
|
||||
@ -72,14 +91,16 @@ type LinterRuleI interface {
|
||||
RuleName() string
|
||||
Run(warn LintWarnFunc, location []parser.Range, txt ...string)
|
||||
IsDeprecated() bool
|
||||
IsExperimental() bool
|
||||
}
|
||||
|
||||
type LinterRule[F any] struct {
|
||||
Name string
|
||||
Description string
|
||||
Deprecated bool
|
||||
URL string
|
||||
Format F
|
||||
Name string
|
||||
Description string
|
||||
Deprecated bool
|
||||
Experimental bool
|
||||
URL string
|
||||
Format F
|
||||
}
|
||||
|
||||
func (rule *LinterRule[F]) RuleName() string {
|
||||
@ -98,6 +119,10 @@ func (rule *LinterRule[F]) IsDeprecated() bool {
|
||||
return rule.Deprecated
|
||||
}
|
||||
|
||||
func (rule *LinterRule[F]) IsExperimental() bool {
|
||||
return rule.Experimental
|
||||
}
|
||||
|
||||
func LintFormatShort(rulename, msg string, line int) string {
|
||||
msg = fmt.Sprintf("%s: %s", rulename, msg)
|
||||
if line > 0 {
|
||||
@ -114,9 +139,9 @@ func ParseLintOptions(checkStr string) (*Config, error) {
|
||||
return &Config{}, nil
|
||||
}
|
||||
|
||||
parts := strings.SplitN(checkStr, ";", 2)
|
||||
var skipSet []string
|
||||
var errorOnWarn, skipAll bool
|
||||
parts := strings.SplitN(checkStr, ";", 3)
|
||||
var skipSet, experimentalSet []string
|
||||
var errorOnWarn, skipAll, experimentalAll bool
|
||||
for _, p := range parts {
|
||||
k, v, ok := strings.Cut(p, "=")
|
||||
if !ok {
|
||||
@ -134,6 +159,16 @@ func ParseLintOptions(checkStr string) (*Config, error) {
|
||||
skipSet[i] = strings.TrimSpace(rule)
|
||||
}
|
||||
}
|
||||
case "experimental":
|
||||
v = strings.TrimSpace(v)
|
||||
if v == "all" {
|
||||
experimentalAll = true
|
||||
} else {
|
||||
experimentalSet = strings.Split(v, ",")
|
||||
for i, rule := range experimentalSet {
|
||||
experimentalSet[i] = strings.TrimSpace(rule)
|
||||
}
|
||||
}
|
||||
case "error":
|
||||
v, err := strconv.ParseBool(strings.TrimSpace(v))
|
||||
if err != nil {
|
||||
@ -145,8 +180,10 @@ func ParseLintOptions(checkStr string) (*Config, error) {
|
||||
}
|
||||
}
|
||||
return &Config{
|
||||
SkipRules: skipSet,
|
||||
SkipAll: skipAll,
|
||||
ReturnAsError: errorOnWarn,
|
||||
ExperimentalAll: experimentalAll,
|
||||
ExperimentalRules: experimentalSet,
|
||||
SkipRules: skipSet,
|
||||
SkipAll: skipAll,
|
||||
ReturnAsError: errorOnWarn,
|
||||
}, nil
|
||||
}
|
||||
|
1
vendor/github.com/moby/buildkit/frontend/dockerfile/linter/ruleset.go
generated
vendored
1
vendor/github.com/moby/buildkit/frontend/dockerfile/linter/ruleset.go
generated
vendored
@ -163,5 +163,6 @@ var (
|
||||
Format: func(cmd, file string) string {
|
||||
return fmt.Sprintf("Attempting to %s file %q that is excluded by .dockerignore", cmd, file)
|
||||
},
|
||||
Experimental: true,
|
||||
}
|
||||
)
|
||||
|
3
vendor/github.com/moby/buildkit/frontend/dockerfile/shell/lex.go
generated
vendored
3
vendor/github.com/moby/buildkit/frontend/dockerfile/shell/lex.go
generated
vendored
@ -378,6 +378,9 @@ func (sw *shellWord) processDollar() (string, error) {
|
||||
fallthrough
|
||||
case '+', '-', '?', '#', '%':
|
||||
rawEscapes := ch == '#' || ch == '%'
|
||||
if nullIsUnset && rawEscapes {
|
||||
return "", errors.Errorf("unsupported modifier (%s) in substitution", chs)
|
||||
}
|
||||
word, _, err := sw.processStopOn('}', rawEscapes)
|
||||
if err != nil {
|
||||
if sw.scanner.Peek() == scanner.EOF {
|
||||
|
50
vendor/github.com/moby/buildkit/frontend/dockerui/config.go
generated
vendored
50
vendor/github.com/moby/buildkit/frontend/dockerui/config.go
generated
vendored
@ -46,30 +46,28 @@ const (
|
||||
|
||||
// Don't forget to update frontend documentation if you add
|
||||
// a new build-arg: frontend/dockerfile/docs/reference.md
|
||||
keyCacheNSArg = "build-arg:BUILDKIT_CACHE_MOUNT_NS"
|
||||
keyMultiPlatformArg = "build-arg:BUILDKIT_MULTI_PLATFORM"
|
||||
keyHostnameArg = "build-arg:BUILDKIT_SANDBOX_HOSTNAME"
|
||||
keyDockerfileLintArg = "build-arg:BUILDKIT_DOCKERFILE_CHECK"
|
||||
keyContextKeepGitDirArg = "build-arg:BUILDKIT_CONTEXT_KEEP_GIT_DIR"
|
||||
keySourceDateEpoch = "build-arg:SOURCE_DATE_EPOCH"
|
||||
keyCopyIgnoredCheckEnabled = "build-arg:BUILDKIT_DOCKERFILE_CHECK_COPYIGNORED_EXPERIMENT"
|
||||
keyCacheNSArg = "build-arg:BUILDKIT_CACHE_MOUNT_NS"
|
||||
keyMultiPlatformArg = "build-arg:BUILDKIT_MULTI_PLATFORM"
|
||||
keyHostnameArg = "build-arg:BUILDKIT_SANDBOX_HOSTNAME"
|
||||
keyDockerfileLintArg = "build-arg:BUILDKIT_DOCKERFILE_CHECK"
|
||||
keyContextKeepGitDirArg = "build-arg:BUILDKIT_CONTEXT_KEEP_GIT_DIR"
|
||||
keySourceDateEpoch = "build-arg:SOURCE_DATE_EPOCH"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
BuildArgs map[string]string
|
||||
CacheIDNamespace string
|
||||
CgroupParent string
|
||||
Epoch *time.Time
|
||||
ExtraHosts []llb.HostIP
|
||||
Hostname string
|
||||
ImageResolveMode llb.ResolveMode
|
||||
Labels map[string]string
|
||||
NetworkMode pb.NetMode
|
||||
ShmSize int64
|
||||
Target string
|
||||
Ulimits []pb.Ulimit
|
||||
LinterConfig *linter.Config
|
||||
CopyIgnoredCheckEnabled bool
|
||||
BuildArgs map[string]string
|
||||
CacheIDNamespace string
|
||||
CgroupParent string
|
||||
Epoch *time.Time
|
||||
ExtraHosts []llb.HostIP
|
||||
Hostname string
|
||||
ImageResolveMode llb.ResolveMode
|
||||
Labels map[string]string
|
||||
NetworkMode pb.NetMode
|
||||
ShmSize int64
|
||||
Target string
|
||||
Ulimits []pb.Ulimit
|
||||
LinterConfig *linter.Config
|
||||
|
||||
CacheImports []client.CacheOptionsEntry
|
||||
TargetPlatforms []ocispecs.Platform // nil means default
|
||||
@ -291,16 +289,6 @@ func (bc *Client) init() error {
|
||||
}
|
||||
}
|
||||
|
||||
// CopyIgnoredCheckEnabled is an experimental feature to check if COPY is ignored by .dockerignore,
|
||||
// and it is disabled by default. It is expected that this feature will be enabled by default in a future
|
||||
// release, and this build-arg will be removed.
|
||||
if v, ok := opts[keyCopyIgnoredCheckEnabled]; ok {
|
||||
bc.CopyIgnoredCheckEnabled, err = strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to parse %s", keyCopyIgnoredCheckEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
bc.localsSessionIDs = parseLocalSessionIDs(opts)
|
||||
|
||||
return nil
|
||||
|
2
vendor/github.com/moby/buildkit/frontend/dockerui/requests.go
generated
vendored
2
vendor/github.com/moby/buildkit/frontend/dockerui/requests.go
generated
vendored
@ -66,7 +66,7 @@ func (bc *Client) HandleSubrequest(ctx context.Context, h RequestHandler) (*clie
|
||||
if warnings == nil {
|
||||
return nil, true, nil
|
||||
}
|
||||
res, err := warnings.ToResult()
|
||||
res, err := warnings.ToResult(nil)
|
||||
return res, true, err
|
||||
}
|
||||
}
|
||||
|
107
vendor/github.com/moby/buildkit/frontend/subrequests/lint/lint.go
generated
vendored
107
vendor/github.com/moby/buildkit/frontend/subrequests/lint/lint.go
generated
vendored
@ -16,6 +16,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type SourceInfoMap func(*pb.SourceInfo) *pb.SourceInfo
|
||||
|
||||
const RequestLint = "frontend.lint"
|
||||
|
||||
var SubrequestLintDefinition = subrequests.Request{
|
||||
@ -39,6 +41,27 @@ type Warning struct {
|
||||
Location pb.Location `json:"location,omitempty"`
|
||||
}
|
||||
|
||||
func (w *Warning) PrintTo(wr io.Writer, sources []*pb.SourceInfo, scb SourceInfoMap) error {
|
||||
fmt.Fprintf(wr, "\nWARNING: %s", w.RuleName)
|
||||
if w.URL != "" {
|
||||
fmt.Fprintf(wr, " - %s", w.URL)
|
||||
}
|
||||
fmt.Fprintf(wr, "\n%s\n", w.Detail)
|
||||
|
||||
if w.Location.SourceIndex < 0 {
|
||||
return nil
|
||||
}
|
||||
sourceInfo := sources[w.Location.SourceIndex]
|
||||
if scb != nil {
|
||||
sourceInfo = scb(sourceInfo)
|
||||
}
|
||||
source := errdefs.Source{
|
||||
Info: sourceInfo,
|
||||
Ranges: w.Location.Ranges,
|
||||
}
|
||||
return source.Print(wr)
|
||||
}
|
||||
|
||||
type BuildError struct {
|
||||
Message string `json:"message"`
|
||||
Location pb.Location `json:"location"`
|
||||
@ -93,7 +116,7 @@ func (results *LintResults) AddWarning(rulename, description, url, fmtmsg string
|
||||
})
|
||||
}
|
||||
|
||||
func (results *LintResults) ToResult() (*client.Result, error) {
|
||||
func (results *LintResults) ToResult(scb SourceInfoMap) (*client.Result, error) {
|
||||
res := client.NewResult()
|
||||
dt, err := json.MarshalIndent(results, "", " ")
|
||||
if err != nil {
|
||||
@ -102,7 +125,7 @@ func (results *LintResults) ToResult() (*client.Result, error) {
|
||||
res.AddMeta("result.json", dt)
|
||||
|
||||
b := bytes.NewBuffer(nil)
|
||||
if err := PrintLintViolations(dt, b); err != nil {
|
||||
if err := PrintLintViolations(dt, b, scb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res.AddMeta("result.txt", b.Bytes())
|
||||
@ -117,28 +140,7 @@ func (results *LintResults) ToResult() (*client.Result, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (results *LintResults) validateWarnings() error {
|
||||
for _, warning := range results.Warnings {
|
||||
if int(warning.Location.SourceIndex) >= len(results.Sources) {
|
||||
return errors.Errorf("sourceIndex is out of range")
|
||||
}
|
||||
if warning.Location.SourceIndex > 0 {
|
||||
warningSource := results.Sources[warning.Location.SourceIndex]
|
||||
if warningSource == nil {
|
||||
return errors.Errorf("sourceIndex points to nil source")
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func PrintLintViolations(dt []byte, w io.Writer) error {
|
||||
var results LintResults
|
||||
|
||||
if err := json.Unmarshal(dt, &results); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
func (results *LintResults) PrintTo(w io.Writer, scb SourceInfoMap) error {
|
||||
if err := results.validateWarnings(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -169,21 +171,7 @@ func PrintLintViolations(dt []byte, w io.Writer) error {
|
||||
})
|
||||
|
||||
for _, warning := range results.Warnings {
|
||||
fmt.Fprintf(w, "\nWARNING: %s", warning.RuleName)
|
||||
if warning.URL != "" {
|
||||
fmt.Fprintf(w, " - %s", warning.URL)
|
||||
}
|
||||
fmt.Fprintf(w, "\n%s\n", warning.Detail)
|
||||
|
||||
if warning.Location.SourceIndex < 0 {
|
||||
continue
|
||||
}
|
||||
sourceInfo := results.Sources[warning.Location.SourceIndex]
|
||||
source := errdefs.Source{
|
||||
Info: sourceInfo,
|
||||
Ranges: warning.Location.Ranges,
|
||||
}
|
||||
err := source.Print(w)
|
||||
err := warning.PrintTo(w, results.Sources, scb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -192,6 +180,47 @@ func PrintLintViolations(dt []byte, w io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (results *LintResults) PrintErrorTo(w io.Writer) {
|
||||
// This prints out the error in LintResults to the writer in a format that
|
||||
// is consistent with the warnings for easier downstream consumption.
|
||||
if results.Error == nil {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Fprintln(w, results.Error.Message)
|
||||
sourceInfo := results.Sources[results.Error.Location.SourceIndex]
|
||||
source := errdefs.Source{
|
||||
Info: sourceInfo,
|
||||
Ranges: results.Error.Location.Ranges,
|
||||
}
|
||||
source.Print(w)
|
||||
}
|
||||
|
||||
func (results *LintResults) validateWarnings() error {
|
||||
for _, warning := range results.Warnings {
|
||||
if int(warning.Location.SourceIndex) >= len(results.Sources) {
|
||||
return errors.Errorf("sourceIndex is out of range")
|
||||
}
|
||||
if warning.Location.SourceIndex > 0 {
|
||||
warningSource := results.Sources[warning.Location.SourceIndex]
|
||||
if warningSource == nil {
|
||||
return errors.Errorf("sourceIndex points to nil source")
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func PrintLintViolations(dt []byte, w io.Writer, scb SourceInfoMap) error {
|
||||
var results LintResults
|
||||
|
||||
if err := json.Unmarshal(dt, &results); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return results.PrintTo(w, scb)
|
||||
}
|
||||
|
||||
func sourceInfoEqual(a, b *pb.SourceInfo) bool {
|
||||
if a.Filename != b.Filename || a.Language != b.Language {
|
||||
return false
|
||||
|
2
vendor/github.com/moby/buildkit/session/secrets/secretsprovider/secretsprovider.go
generated
vendored
2
vendor/github.com/moby/buildkit/session/secrets/secretsprovider/secretsprovider.go
generated
vendored
@ -32,7 +32,7 @@ func (sp *secretProvider) GetSecret(ctx context.Context, req *secrets.GetSecretR
|
||||
dt, err := sp.store.GetSecret(ctx, req.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, secrets.ErrNotFound) {
|
||||
return nil, status.Errorf(codes.NotFound, err.Error())
|
||||
return nil, status.Error(codes.NotFound, err.Error())
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
11
vendor/github.com/moby/buildkit/session/upload/uploadprovider/provider.go
generated
vendored
11
vendor/github.com/moby/buildkit/session/upload/uploadprovider/provider.go
generated
vendored
@ -13,15 +13,15 @@ import (
|
||||
)
|
||||
|
||||
func New() *Uploader {
|
||||
return &Uploader{m: map[string]io.Reader{}}
|
||||
return &Uploader{m: map[string]io.ReadCloser{}}
|
||||
}
|
||||
|
||||
type Uploader struct {
|
||||
mu sync.Mutex
|
||||
m map[string]io.Reader
|
||||
m map[string]io.ReadCloser
|
||||
}
|
||||
|
||||
func (hp *Uploader) Add(r io.Reader) string {
|
||||
func (hp *Uploader) Add(r io.ReadCloser) string {
|
||||
id := identity.NewID()
|
||||
hp.m[id] = r
|
||||
return "http://buildkit-session/" + id
|
||||
@ -51,6 +51,11 @@ func (hp *Uploader) Pull(stream upload.Upload_PullServer) error {
|
||||
hp.mu.Unlock()
|
||||
|
||||
_, err := io.Copy(&writer{stream}, r)
|
||||
|
||||
if err1 := r.Close(); err == nil {
|
||||
err = err1
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
2
vendor/github.com/moby/buildkit/util/appcontext/appcontext.go
generated
vendored
2
vendor/github.com/moby/buildkit/util/appcontext/appcontext.go
generated
vendored
@ -38,7 +38,7 @@ func Context() context.Context {
|
||||
err := errors.Errorf("got %d SIGTERM/SIGINTs, forcing shutdown", retries)
|
||||
cancel(err)
|
||||
if retries >= exitLimit {
|
||||
bklog.G(ctx).Errorf(err.Error())
|
||||
bklog.G(ctx).Error(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
6
vendor/github.com/moby/buildkit/util/appdefaults/appdefaults_linux.go
generated
vendored
Normal file
6
vendor/github.com/moby/buildkit/util/appdefaults/appdefaults_linux.go
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
package appdefaults
|
||||
|
||||
const (
|
||||
Address = "unix:///run/buildkit/buildkitd.sock"
|
||||
traceSocketPath = "/run/buildkit/otel-grpc.sock"
|
||||
)
|
3
vendor/github.com/moby/buildkit/util/appdefaults/appdefaults_unix.go
generated
vendored
3
vendor/github.com/moby/buildkit/util/appdefaults/appdefaults_unix.go
generated
vendored
@ -10,7 +10,6 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
Address = "unix:///run/buildkit/buildkitd.sock"
|
||||
Root = "/var/lib/buildkit"
|
||||
ConfigDir = "/etc/buildkit"
|
||||
DefaultCNIBinDir = "/opt/cni/bin"
|
||||
@ -82,5 +81,5 @@ func TraceSocketPath(inUserNS bool) string {
|
||||
return filepath.Join(dirs[0], "buildkit", "otel-grpc.sock")
|
||||
}
|
||||
}
|
||||
return "/run/buildkit/otel-grpc.sock"
|
||||
return traceSocketPath
|
||||
}
|
||||
|
8
vendor/github.com/moby/buildkit/util/appdefaults/appdefaults_unix_nolinux.go
generated
vendored
Normal file
8
vendor/github.com/moby/buildkit/util/appdefaults/appdefaults_unix_nolinux.go
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
//go:build unix && !linux
|
||||
|
||||
package appdefaults
|
||||
|
||||
const (
|
||||
Address = "unix:///var/run/buildkit/buildkitd.sock"
|
||||
traceSocketPath = "/var/run/buildkit/otel-grpc.sock"
|
||||
)
|
3
vendor/github.com/moby/buildkit/util/grpcerrors/grpcerrors.go
generated
vendored
3
vendor/github.com/moby/buildkit/util/grpcerrors/grpcerrors.go
generated
vendored
@ -96,6 +96,9 @@ func withDetails(ctx context.Context, s *status.Status, details ...proto.Message
|
||||
|
||||
func Code(err error) codes.Code {
|
||||
if errdefs.IsInternal(err) {
|
||||
if errdefs.IsResourceExhausted(err) {
|
||||
return codes.ResourceExhausted
|
||||
}
|
||||
return codes.Internal
|
||||
}
|
||||
|
||||
|
2
vendor/github.com/moby/buildkit/util/resolver/retryhandler/retry.go
generated
vendored
2
vendor/github.com/moby/buildkit/util/resolver/retryhandler/retry.go
generated
vendored
@ -64,7 +64,7 @@ func retryError(err error) bool {
|
||||
return true
|
||||
}
|
||||
// catches TLS timeout or other network-related temporary errors
|
||||
if ne := net.Error(nil); errors.As(err, &ne) && ne.Temporary() { //nolint:staticcheck // ignoring "SA1019: Temporary is deprecated", continue to propagate net.Error through the "temporary" status
|
||||
if ne := net.Error(nil); errors.As(err, &ne) && ne.Temporary() { // ignoring "SA1019: Temporary is deprecated", continue to propagate net.Error through the "temporary" status
|
||||
return true
|
||||
}
|
||||
|
||||
|
67
vendor/github.com/moby/buildkit/util/stack/compress.go
generated
vendored
Normal file
67
vendor/github.com/moby/buildkit/util/stack/compress.go
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
package stack
|
||||
|
||||
import (
|
||||
"slices"
|
||||
)
|
||||
|
||||
func compressStacks(st []*Stack) []*Stack {
|
||||
if len(st) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
slices.SortFunc(st, func(a, b *Stack) int {
|
||||
return len(b.Frames) - len(a.Frames)
|
||||
})
|
||||
|
||||
out := []*Stack{st[0]}
|
||||
|
||||
loop0:
|
||||
for _, st := range st[1:] {
|
||||
maxIdx := -1
|
||||
for _, prev := range out {
|
||||
idx := subFrames(st.Frames, prev.Frames)
|
||||
if idx == -1 {
|
||||
continue
|
||||
}
|
||||
// full match, potentially skip all
|
||||
if idx == len(st.Frames)-1 {
|
||||
if st.Pid == prev.Pid && st.Version == prev.Version && slices.Compare(st.Cmdline, st.Cmdline) == 0 {
|
||||
continue loop0
|
||||
}
|
||||
}
|
||||
if idx > maxIdx {
|
||||
maxIdx = idx
|
||||
}
|
||||
}
|
||||
|
||||
if maxIdx > 0 {
|
||||
st.Frames = st.Frames[:len(st.Frames)-maxIdx]
|
||||
}
|
||||
out = append(out, st)
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func subFrames(a, b []*Frame) int {
|
||||
idx := -1
|
||||
i := len(a) - 1
|
||||
j := len(b) - 1
|
||||
for i >= 0 {
|
||||
if j < 0 {
|
||||
break
|
||||
}
|
||||
if a[i].Equal(b[j]) {
|
||||
idx++
|
||||
i--
|
||||
j--
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return idx
|
||||
}
|
||||
|
||||
func (a *Frame) Equal(b *Frame) bool {
|
||||
return a.File == b.File && a.Line == b.Line && a.Name == b.Name
|
||||
}
|
4
vendor/github.com/moby/buildkit/util/stack/stack.go
generated
vendored
4
vendor/github.com/moby/buildkit/util/stack/stack.go
generated
vendored
@ -44,6 +44,10 @@ func Helper() {
|
||||
}
|
||||
|
||||
func Traces(err error) []*Stack {
|
||||
return compressStacks(traces(err))
|
||||
}
|
||||
|
||||
func traces(err error) []*Stack {
|
||||
var st []*Stack
|
||||
|
||||
switch e := err.(type) {
|
||||
|
2
vendor/github.com/moby/buildkit/util/testutil/integration/run.go
generated
vendored
2
vendor/github.com/moby/buildkit/util/testutil/integration/run.go
generated
vendored
@ -220,7 +220,7 @@ func Run(t *testing.T, testCases []Test, opt ...TestOpt) {
|
||||
func getFunctionName(i interface{}) string {
|
||||
fullname := runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
|
||||
dot := strings.LastIndex(fullname, ".") + 1
|
||||
return strings.Title(fullname[dot:]) //nolint:staticcheck // ignoring "SA1019: strings.Title is deprecated", as for our use we don't need full unicode support
|
||||
return strings.Title(fullname[dot:]) // ignoring "SA1019: strings.Title is deprecated", as for our use we don't need full unicode support
|
||||
}
|
||||
|
||||
var localImageCache map[string]map[string]struct{}
|
||||
|
4
vendor/github.com/moby/buildkit/util/testutil/integration/sandbox.go
generated
vendored
4
vendor/github.com/moby/buildkit/util/testutil/integration/sandbox.go
generated
vendored
@ -59,6 +59,8 @@ func (sb *sandbox) NewRegistry() (string, error) {
|
||||
|
||||
func (sb *sandbox) Cmd(args ...string) *exec.Cmd {
|
||||
if len(args) == 1 {
|
||||
// \\ being stripped off for Windows paths, convert to unix style
|
||||
args[0] = strings.ReplaceAll(args[0], "\\", "/")
|
||||
if split, err := shlex.Split(args[0]); err == nil {
|
||||
args = split
|
||||
}
|
||||
@ -151,7 +153,7 @@ func FormatLogs(m map[string]*bytes.Buffer) string {
|
||||
func CheckFeatureCompat(t *testing.T, sb Sandbox, features map[string]struct{}, reason ...string) {
|
||||
t.Helper()
|
||||
if err := HasFeatureCompat(t, sb, features, reason...); err != nil {
|
||||
t.Skipf(err.Error())
|
||||
t.Skip(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
4
vendor/github.com/moby/buildkit/util/testutil/integration/util_windows.go
generated
vendored
4
vendor/github.com/moby/buildkit/util/testutil/integration/util_windows.go
generated
vendored
@ -16,6 +16,10 @@ var windowsImagesMirrorMap = map[string]string{
|
||||
"nanoserver:latest": "mcr.microsoft.com/windows/nanoserver:ltsc2022",
|
||||
"servercore:latest": "mcr.microsoft.com/windows/servercore:ltsc2022",
|
||||
"busybox:latest": "registry.k8s.io/e2e-test-images/busybox@sha256:6d854ffad9666d2041b879a1c128c9922d77faced7745ad676639b07111ab650",
|
||||
// nanoserver with extra binaries, like fc.exe
|
||||
// TODO(profnandaa): get an approved/compliant repo, placeholder for now
|
||||
// see dockerfile here - https://github.com/microsoft/windows-container-tools/pull/178
|
||||
"nanoserver:plus": "docker.io/wintools/nanoserver:ltsc2022",
|
||||
}
|
||||
|
||||
// abstracted function to handle pipe dialing on windows.
|
||||
|
Reference in New Issue
Block a user