Fix empty string id in result ref

Signed-off-by: Edgar Lee <edgarl@netflix.com>
v0.7
Edgar Lee 2019-12-05 11:08:12 -08:00
parent b622a87c5d
commit 7562a6638a
3 changed files with 13 additions and 4 deletions

View File

@ -479,7 +479,7 @@ func (lbf *llbBridgeForwarder) Solve(ctx context.Context, req *pb.SolveRequest)
if req.AllowResultArrayRef {
refMap := make(map[string]*pb.Ref, len(res.Refs))
for k, id := range ids {
refMap[k] = &pb.Ref{Ids: []string{id}}
refMap[k] = pb.NewRef(id)
}
pbRes.Result = &pb.Result_Refs{Refs: &pb.RefMap{Refs: refMap}}
} else {
@ -495,7 +495,7 @@ func (lbf *llbBridgeForwarder) Solve(ctx context.Context, req *pb.SolveRequest)
defaultID = id
if req.AllowResultArrayRef {
pbRes.Result = &pb.Result_Ref{Ref: &pb.Ref{Ids: []string{id}}}
pbRes.Result = &pb.Result_Ref{Ref: pb.NewRef(id)}
} else {
pbRes.Result = &pb.Result_RefDeprecated{RefDeprecated: id}
}

View File

@ -112,7 +112,7 @@ func (c *grpcClient) Run(ctx context.Context, f client.BuildFunc) (retError erro
retError = err
continue
}
m[k] = &pb.Ref{Ids: []string{id}}
m[k] = pb.NewRef(id)
}
pbRes.Result = &pb.Result_Refs{Refs: &pb.RefMap{Refs: m}}
} else {
@ -120,7 +120,7 @@ func (c *grpcClient) Run(ctx context.Context, f client.BuildFunc) (retError erro
if err != nil {
retError = err
} else {
pbRes.Result = &pb.Result_Ref{Ref: &pb.Ref{Ids: []string{id}}}
pbRes.Result = &pb.Result_Ref{Ref: pb.NewRef(id)}
}
}
if retError == nil {

View File

@ -0,0 +1,9 @@
package moby_buildkit_v1_frontend
func NewRef(id string) *Ref {
var ref Ref
if id != "" {
ref.Ids = append(ref.Ids, id)
}
return &ref
}