Skip to content

Commit 035236a

Browse files
committed
driver: handle nil logger for bootstrap
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 <[email protected]>
1 parent 99777ea commit 035236a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

driver/driver.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ func ParseBuilderName(name string) (string, error) {
8383

8484
func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Writer) (*client.Client, error) {
8585
try := 0
86+
logger := discardLogger
87+
if pw != nil {
88+
logger = pw.Write
89+
}
90+
8691
for {
8792
info, err := d.Info(ctx)
8893
if err != nil {
@@ -93,7 +98,7 @@ func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Write
9398
if try > 2 {
9499
return nil, errors.Errorf("failed to bootstrap %T driver in attempts", d)
95100
}
96-
if err := d.Bootstrap(ctx, pw.Write); err != nil {
101+
if err := d.Bootstrap(ctx, logger); err != nil {
97102
return nil, err
98103
}
99104
}
@@ -109,6 +114,8 @@ func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Write
109114
}
110115
}
111116

117+
func discardLogger(*client.SolveStatus) {}
118+
112119
func historyAPISupported(ctx context.Context, c *client.Client) bool {
113120
cl, err := c.ControlClient().ListenBuildHistory(ctx, &controlapi.BuildHistoryRequest{
114121
ActiveOnly: true,

0 commit comments

Comments
 (0)