mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-20 18:28:03 +08:00
build: fix build details link in experimental mode
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package errdefs
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"github.com/docker/buildx/util/desktop"
|
||||
"github.com/moby/buildkit/util/grpcerrors"
|
||||
)
|
||||
|
||||
@@ -22,11 +25,22 @@ func (e *BuildError) ToProto() grpcerrors.TypedErrorProto {
|
||||
return e.Build
|
||||
}
|
||||
|
||||
func WrapBuild(err error, ref string) error {
|
||||
func (e *BuildError) PrintBuildDetails(w io.Writer) error {
|
||||
if e.BuildRef == "" {
|
||||
return nil
|
||||
}
|
||||
ebr := &desktop.ErrorWithBuildRef{
|
||||
Ref: e.BuildRef,
|
||||
Err: e.error,
|
||||
}
|
||||
return ebr.Print(w)
|
||||
}
|
||||
|
||||
func WrapBuild(err error, ref string, buildRef string) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return &BuildError{Build: &Build{Ref: ref}, error: err}
|
||||
return &BuildError{Build: &Build{Ref: ref, BuildRef: buildRef}, error: err}
|
||||
}
|
||||
|
||||
func (b *Build) WrapError(err error) error {
|
||||
|
@@ -25,7 +25,8 @@ type Build struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Ref string `protobuf:"bytes,1,opt,name=Ref,proto3" json:"Ref,omitempty"`
|
||||
Ref string `protobuf:"bytes,1,opt,name=Ref,proto3" json:"Ref,omitempty"`
|
||||
BuildRef string `protobuf:"bytes,2,opt,name=BuildRef,proto3" json:"BuildRef,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Build) Reset() {
|
||||
@@ -67,6 +68,13 @@ func (x *Build) GetRef() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Build) GetBuildRef() string {
|
||||
if x != nil {
|
||||
return x.BuildRef
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_github_com_docker_buildx_controller_errdefs_errdefs_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_github_com_docker_buildx_controller_errdefs_errdefs_proto_rawDesc = []byte{
|
||||
@@ -75,12 +83,13 @@ var file_github_com_docker_buildx_controller_errdefs_errdefs_proto_rawDesc = []b
|
||||
0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x65, 0x72, 0x72, 0x64, 0x65, 0x66, 0x73, 0x2f, 0x65, 0x72,
|
||||
0x72, 0x64, 0x65, 0x66, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x64, 0x6f, 0x63,
|
||||
0x6b, 0x65, 0x72, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x78, 0x2e, 0x65, 0x72, 0x72, 0x64, 0x65,
|
||||
0x66, 0x73, 0x22, 0x19, 0x0a, 0x05, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x52,
|
||||
0x65, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x52, 0x65, 0x66, 0x42, 0x2d, 0x5a,
|
||||
0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, 0x63, 0x6b,
|
||||
0x65, 0x72, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x78, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f,
|
||||
0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x65, 0x72, 0x72, 0x64, 0x65, 0x66, 0x73, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
0x66, 0x73, 0x22, 0x35, 0x0a, 0x05, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x52,
|
||||
0x65, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x52, 0x65, 0x66, 0x12, 0x1a, 0x0a,
|
||||
0x08, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x66, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x08, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x66, 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74,
|
||||
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2f, 0x62,
|
||||
0x75, 0x69, 0x6c, 0x64, 0x78, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72,
|
||||
0x2f, 0x65, 0x72, 0x72, 0x64, 0x65, 0x66, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@@ -6,4 +6,5 @@ option go_package = "github.com/docker/buildx/controller/errdefs";
|
||||
|
||||
message Build {
|
||||
string Ref = 1;
|
||||
string BuildRef = 2;
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ func (m *Build) CloneVT() *Build {
|
||||
}
|
||||
r := new(Build)
|
||||
r.Ref = m.Ref
|
||||
r.BuildRef = m.BuildRef
|
||||
if len(m.unknownFields) > 0 {
|
||||
r.unknownFields = make([]byte, len(m.unknownFields))
|
||||
copy(r.unknownFields, m.unknownFields)
|
||||
@@ -45,6 +46,9 @@ func (this *Build) EqualVT(that *Build) bool {
|
||||
if this.Ref != that.Ref {
|
||||
return false
|
||||
}
|
||||
if this.BuildRef != that.BuildRef {
|
||||
return false
|
||||
}
|
||||
return string(this.unknownFields) == string(that.unknownFields)
|
||||
}
|
||||
|
||||
@@ -85,6 +89,13 @@ func (m *Build) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
||||
i -= len(m.unknownFields)
|
||||
copy(dAtA[i:], m.unknownFields)
|
||||
}
|
||||
if len(m.BuildRef) > 0 {
|
||||
i -= len(m.BuildRef)
|
||||
copy(dAtA[i:], m.BuildRef)
|
||||
i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.BuildRef)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.Ref) > 0 {
|
||||
i -= len(m.Ref)
|
||||
copy(dAtA[i:], m.Ref)
|
||||
@@ -105,6 +116,10 @@ func (m *Build) SizeVT() (n int) {
|
||||
if l > 0 {
|
||||
n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
|
||||
}
|
||||
l = len(m.BuildRef)
|
||||
if l > 0 {
|
||||
n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
|
||||
}
|
||||
n += len(m.unknownFields)
|
||||
return n
|
||||
}
|
||||
@@ -170,6 +185,38 @@ func (m *Build) UnmarshalVT(dAtA []byte) error {
|
||||
}
|
||||
m.Ref = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field BuildRef", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protohelpers.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return protohelpers.ErrInvalidLength
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return protohelpers.ErrInvalidLength
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.BuildRef = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := protohelpers.Skip(dAtA[iNdEx:])
|
||||
|
Reference in New Issue
Block a user