Introduce a client interface, to abstract from buildkit client.

This will allow further enhancement like caching remote driver responses.

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
This commit is contained in:
Silvin Lubecki
2023-08-08 14:44:42 +02:00
parent 561a4330cf
commit 2aa6d52b06
9 changed files with 36 additions and 17 deletions

View File

@ -8,7 +8,6 @@ import (
"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/pkg/errors"
)
@ -58,13 +57,13 @@ type Driver interface {
Version(context.Context) (string, error)
Stop(ctx context.Context, force bool) error
Rm(ctx context.Context, force, rmVolume, rmDaemon bool) error
Client(ctx context.Context) (*client.Client, error)
Client(ctx context.Context) (Client, error)
Features(ctx context.Context) map[Feature]bool
IsMobyDriver() bool
Config() InitConfig
}
func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Writer) (*client.Client, error) {
func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Writer) (Client, error) {
try := 0
for {
info, err := d.Info(ctx)
@ -92,7 +91,7 @@ func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Write
}
}
func historyAPISupported(ctx context.Context, c *client.Client) bool {
func historyAPISupported(ctx context.Context, c Client) bool {
cl, err := c.ControlClient().ListenBuildHistory(ctx, &controlapi.BuildHistoryRequest{
ActiveOnly: true,
Ref: "buildx-test-history-api-feature", // dummy ref to check if the server supports the API