Skip to content

Commit 0758a9b

Browse files
authored
Merge pull request #1856 from crazy-max/history-feature-update
driver: update history api check
2 parents 4abff3c + f8fa526 commit 0758a9b

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

driver/driver.go

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ package driver
22

33
import (
44
"context"
5+
"io"
56

67
"github.com/docker/buildx/store"
78
"github.com/docker/buildx/util/progress"
89
clitypes "github.com/docker/cli/cli/config/types"
910
controlapi "github.com/moby/buildkit/api/services/control"
1011
"github.com/moby/buildkit/client"
11-
"github.com/moby/buildkit/util/grpcerrors"
1212
"github.com/pkg/errors"
13-
"google.golang.org/grpc/codes"
1413
)
1514

1615
var ErrNotRunning = errors.Errorf("driver not running")
@@ -93,25 +92,21 @@ func Boot(ctx, clientContext context.Context, d Driver, pw progress.Writer) (*cl
9392
}
9493
}
9594

96-
func HistoryAPISupported(ctx context.Context, c *client.Client) (res bool) {
97-
res = true
98-
checkErrF := func(err error) {
99-
if s, ok := grpcerrors.AsGRPCStatus(err); ok {
100-
if s.Code() == codes.Unimplemented {
101-
res = false
102-
}
103-
}
104-
}
95+
func HistoryAPISupported(ctx context.Context, c *client.Client) bool {
10596
cl, err := c.ControlClient().ListenBuildHistory(ctx, &controlapi.BuildHistoryRequest{
10697
ActiveOnly: true,
107-
Ref: "buildx-dummy-ref", // dummy ref to check if the server supports the API
98+
Ref: "buildx-test-history-api-feature", // dummy ref to check if the server supports the API
10899
EarlyExit: true,
109100
})
110101
if err != nil {
111-
checkErrF(err)
112-
return
102+
return false
103+
}
104+
for {
105+
_, err := cl.Recv()
106+
if errors.Is(err, io.EOF) {
107+
return true
108+
} else if err != nil {
109+
return false
110+
}
113111
}
114-
_, err = cl.Recv()
115-
checkErrF(err)
116-
return
117112
}

0 commit comments

Comments
 (0)