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 <tonistiigi@gmail.com>
(cherry picked from commit 035236a5ed334fdbaa28b976c473ab4161cd4cc8)
This commit is contained in:
Tonis Tiigi 2024-05-20 16:38:01 -07:00
parent 6a84f43fba
commit a3b1fae96d
No known key found for this signature in database
GPG Key ID: AFA9DE5F8AB7AF39

View File

@ -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 {
@ -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
}
}
@ -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,