diff --git a/driver/driver.go b/driver/driver.go index aa378058..3627226c 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -2,15 +2,14 @@ package driver import ( "context" + "io" "github.com/docker/buildx/store" "github.com/docker/buildx/util/progress" clitypes "github.com/docker/cli/cli/config/types" controlapi "github.com/moby/buildkit/api/services/control" "github.com/moby/buildkit/client" - "github.com/moby/buildkit/util/grpcerrors" "github.com/pkg/errors" - "google.golang.org/grpc/codes" ) var ErrNotRunning = errors.Errorf("driver not running") @@ -93,25 +92,21 @@ func Boot(ctx, clientContext context.Context, d Driver, pw progress.Writer) (*cl } } -func HistoryAPISupported(ctx context.Context, c *client.Client) (res bool) { - res = true - checkErrF := func(err error) { - if s, ok := grpcerrors.AsGRPCStatus(err); ok { - if s.Code() == codes.Unimplemented { - res = false - } - } - } +func HistoryAPISupported(ctx context.Context, c *client.Client) bool { cl, err := c.ControlClient().ListenBuildHistory(ctx, &controlapi.BuildHistoryRequest{ ActiveOnly: true, - Ref: "buildx-dummy-ref", // dummy ref to check if the server supports the API + Ref: "buildx-test-history-api-feature", // dummy ref to check if the server supports the API EarlyExit: true, }) if err != nil { - checkErrF(err) - return + return false + } + for { + _, err := cl.Recv() + if errors.Is(err, io.EOF) { + return true + } else if err != nil { + return false + } } - _, err = cl.Recv() - checkErrF(err) - return }