mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
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:
parent
6a84f43fba
commit
a3b1fae96d
@ -83,6 +83,11 @@ func ParseBuilderName(name string) (string, error) {
|
|||||||
|
|
||||||
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.Client, error) {
|
||||||
try := 0
|
try := 0
|
||||||
|
logger := discardLogger
|
||||||
|
if pw != nil {
|
||||||
|
logger = pw.Write
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
info, err := d.Info(ctx)
|
info, err := d.Info(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -93,7 +98,7 @@ func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Write
|
|||||||
if try > 2 {
|
if try > 2 {
|
||||||
return nil, errors.Errorf("failed to bootstrap %T driver in attempts", d)
|
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
|
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 {
|
func historyAPISupported(ctx context.Context, c *client.Client) bool {
|
||||||
cl, err := c.ControlClient().ListenBuildHistory(ctx, &controlapi.BuildHistoryRequest{
|
cl, err := c.ControlClient().ListenBuildHistory(ctx, &controlapi.BuildHistoryRequest{
|
||||||
ActiveOnly: true,
|
ActiveOnly: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user