Skip to content

Commit

Permalink
driver: handle nil logger for bootstrap
Browse files Browse the repository at this point in the history
resolveNode methods can call with nil logger. Although
the results should already be cached now in resolver
this makes the protection more explicit.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 035236a)
  • Loading branch information
tonistiigi committed May 22, 2024
1 parent 6a84f43 commit a3b1fae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ func ParseBuilderName(name string) (string, error) {

func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Writer) (*client.Client, error) {
try := 0
logger := discardLogger
if pw != nil {
logger = pw.Write
}

for {
info, err := d.Info(ctx)
if err != nil {
Expand All @@ -93,7 +98,7 @@ func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Write
if try > 2 {
return nil, errors.Errorf("failed to bootstrap %T driver in attempts", d)
}
if err := d.Bootstrap(ctx, pw.Write); err != nil {
if err := d.Bootstrap(ctx, logger); err != nil {
return nil, err
}
}
Expand All @@ -109,6 +114,8 @@ func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Write
}
}

func discardLogger(*client.SolveStatus) {}

func historyAPISupported(ctx context.Context, c *client.Client) bool {
cl, err := c.ControlClient().ListenBuildHistory(ctx, &controlapi.BuildHistoryRequest{
ActiveOnly: true,
Expand Down

0 comments on commit a3b1fae

Please sign in to comment.