mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
build: add experimental support for print flag
Print flag can be used to make additional information requests about the build and print their results. Currently Dockerfile supports: outline, targets, subrequests.describe Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
95
vendor/github.com/moby/buildkit/util/gitutil/git_ref.go
generated
vendored
Normal file
95
vendor/github.com/moby/buildkit/util/gitutil/git_ref.go
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
package gitutil
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
)
|
||||
|
||||
// GitRef represents a git ref.
|
||||
//
|
||||
// Examples:
|
||||
// - "https://github.com/foo/bar.git#baz/qux:quux/quuz" is parsed into:
|
||||
// {Remote: "https://github.com/foo/bar.git", ShortName: "bar", Commit:"baz/qux", SubDir: "quux/quuz"}.
|
||||
type GitRef struct {
|
||||
// Remote is the remote repository path.
|
||||
Remote string
|
||||
|
||||
// ShortName is the directory name of the repo.
|
||||
// e.g., "bar" for "https://github.com/foo/bar.git"
|
||||
ShortName string
|
||||
|
||||
// Commit is a commit hash, a tag, or branch name.
|
||||
// Commit is optional.
|
||||
Commit string
|
||||
|
||||
// SubDir is a directory path inside the repo.
|
||||
// SubDir is optional.
|
||||
SubDir string
|
||||
|
||||
// IndistinguishableFromLocal is true for a ref that is indistinguishable from a local file path,
|
||||
// e.g., "github.com/foo/bar".
|
||||
//
|
||||
// Deprecated.
|
||||
// Instead, use a distinguishable form such as "https://github.com/foo/bar.git".
|
||||
//
|
||||
// The dockerfile frontend still accepts this form only for build contexts.
|
||||
IndistinguishableFromLocal bool
|
||||
|
||||
// UnencryptedTCP is true for a ref that needs an unencrypted TCP connection,
|
||||
// e.g., "git://..." and "http://..." .
|
||||
//
|
||||
// Discouraged, although not deprecated.
|
||||
// Instead, consider using an encrypted TCP connection such as "git@github.com/foo/bar.git" or "https://github.com/foo/bar.git".
|
||||
UnencryptedTCP bool
|
||||
}
|
||||
|
||||
// var gitURLPathWithFragmentSuffix = regexp.MustCompile(`\.git(?:#.+)?$`)
|
||||
|
||||
// ParseGitRef parses a git ref.
|
||||
func ParseGitRef(ref string) (*GitRef, error) {
|
||||
res := &GitRef{}
|
||||
|
||||
if strings.HasPrefix(ref, "github.com/") {
|
||||
res.IndistinguishableFromLocal = true // Deprecated
|
||||
} else {
|
||||
_, proto := ParseProtocol(ref)
|
||||
switch proto {
|
||||
case UnknownProtocol:
|
||||
return nil, errdefs.ErrInvalidArgument
|
||||
}
|
||||
switch proto {
|
||||
case HTTPProtocol, GitProtocol:
|
||||
res.UnencryptedTCP = true // Discouraged, but not deprecated
|
||||
}
|
||||
switch proto {
|
||||
// An HTTP(S) URL is considered to be a valid git ref only when it has the ".git[...]" suffix.
|
||||
case HTTPProtocol, HTTPSProtocol:
|
||||
var gitURLPathWithFragmentSuffix = regexp.MustCompile(`\.git(?:#.+)?$`)
|
||||
if !gitURLPathWithFragmentSuffix.MatchString(ref) {
|
||||
return nil, errdefs.ErrInvalidArgument
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
refSplitBySharp := strings.SplitN(ref, "#", 2)
|
||||
res.Remote = refSplitBySharp[0]
|
||||
if len(res.Remote) == 0 {
|
||||
return res, errdefs.ErrInvalidArgument
|
||||
}
|
||||
|
||||
if len(refSplitBySharp) > 1 {
|
||||
refSplitBySharpSplitByColon := strings.SplitN(refSplitBySharp[1], ":", 2)
|
||||
res.Commit = refSplitBySharpSplitByColon[0]
|
||||
if len(res.Commit) == 0 {
|
||||
return res, errdefs.ErrInvalidArgument
|
||||
}
|
||||
if len(refSplitBySharpSplitByColon) > 1 {
|
||||
res.SubDir = refSplitBySharpSplitByColon[1]
|
||||
}
|
||||
}
|
||||
repoSplitBySlash := strings.Split(res.Remote, "/")
|
||||
res.ShortName = strings.TrimSuffix(repoSplitBySlash[len(repoSplitBySlash)-1], ".git")
|
||||
return res, nil
|
||||
}
|
8
vendor/github.com/moby/buildkit/util/grpcerrors/grpcerrors.go
generated
vendored
8
vendor/github.com/moby/buildkit/util/grpcerrors/grpcerrors.go
generated
vendored
@ -42,6 +42,14 @@ func ToGRPC(err error) error {
|
||||
st = status.FromProto(pb)
|
||||
}
|
||||
|
||||
// If the original error was wrapped with more context than the GRPCStatus error,
|
||||
// copy the original message to the GRPCStatus error
|
||||
if err.Error() != st.Message() {
|
||||
pb := st.Proto()
|
||||
pb.Message = err.Error()
|
||||
st = status.FromProto(pb)
|
||||
}
|
||||
|
||||
var details []proto.Message
|
||||
|
||||
for _, st := range stack.Traces(err) {
|
||||
|
6
vendor/github.com/moby/buildkit/util/resolver/retryhandler/retry.go
generated
vendored
6
vendor/github.com/moby/buildkit/util/resolver/retryhandler/retry.go
generated
vendored
@ -14,6 +14,10 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// MaxRetryBackoff is the maximum backoff time before giving up. This is a
|
||||
// variable so that code which embeds BuildKit can override the default value.
|
||||
var MaxRetryBackoff = 8 * time.Second
|
||||
|
||||
func New(f images.HandlerFunc, logger func([]byte)) images.HandlerFunc {
|
||||
return func(ctx context.Context, desc ocispecs.Descriptor) ([]ocispecs.Descriptor, error) {
|
||||
backoff := time.Second
|
||||
@ -35,7 +39,7 @@ func New(f images.HandlerFunc, logger func([]byte)) images.HandlerFunc {
|
||||
return descs, nil
|
||||
}
|
||||
// backoff logic
|
||||
if backoff >= 8*time.Second {
|
||||
if backoff >= MaxRetryBackoff {
|
||||
return nil, err
|
||||
}
|
||||
if logger != nil {
|
||||
|
Reference in New Issue
Block a user