solver/client: add ability to disable the cache at the LLB level

Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
Sam Alba
2021-04-14 16:21:18 -07:00
parent 3bc91530e0
commit 83f56897a7
2 changed files with 36 additions and 5 deletions

View File

@@ -29,10 +29,11 @@ import (
// A dagger client
type Client struct {
c *bk.Client
c *bk.Client
noCache bool
}
func NewClient(ctx context.Context, host string) (*Client, error) {
func NewClient(ctx context.Context, host string, noCache bool) (*Client, error) {
if host == "" {
host = os.Getenv("BUILDKIT_HOST")
}
@@ -53,7 +54,8 @@ func NewClient(ctx context.Context, host string) (*Client, error) {
return nil, fmt.Errorf("buildkit client: %w", err)
}
return &Client{
c: c,
c: c,
noCache: noCache,
}, nil
}
@@ -111,7 +113,7 @@ func (c *Client) buildfn(ctx context.Context, deployment *Deployment, fn ClientD
Msg("spawning buildkit job")
resp, err := c.c.Build(ctx, opts, "", func(ctx context.Context, gw bkgw.Client) (*bkgw.Result, error) {
s := NewSolver(c.c, gw, ch)
s := NewSolver(c.c, gw, ch, c.noCache)
lg.Debug().Msg("loading configuration")
if err := deployment.LoadPlan(ctx, s); err != nil {