MCPcopy Create free account
hub / github.com/docker/buildx / Boot

Method Boot

builder/builder.go:162–209  ·  view source on GitHub ↗

Boot bootstrap a builder

(ctx context.Context)

Source from the content-addressed store, hash-verified

160
161// Boot bootstrap a builder
162func (b *Builder) Boot(ctx context.Context) (bool, error) {
163 toBoot := make([]int, 0, len(b.nodes))
164 for idx, d := range b.nodes {
165 if d.Err != nil || d.Driver == nil || d.DriverInfo == nil {
166 continue
167 }
168 if d.DriverInfo.Status != driver.Running {
169 toBoot = append(toBoot, idx)
170 }
171 }
172 if len(toBoot) == 0 {
173 return false, nil
174 }
175
176 printer, err := progress.NewPrinter(context.TODO(), os.Stderr, progressui.AutoMode)
177 if err != nil {
178 return false, err
179 }
180
181 baseCtx := ctx
182 eg, _ := errgroup.WithContext(ctx)
183 errCh := make(chan error, len(toBoot))
184 for _, idx := range toBoot {
185 func(idx int) {
186 eg.Go(func() error {
187 pw := progress.WithPrefix(printer, b.NodeGroup.Nodes[idx].Name, len(toBoot) > 1)
188 _, err := driver.Boot(ctx, baseCtx, b.nodes[idx].Driver, pw)
189 if err != nil {
190 b.nodes[idx].Err = err
191 errCh <- err
192 }
193 return nil
194 })
195 }(idx)
196 }
197
198 err = eg.Wait()
199 close(errCh)
200 err1 := printer.Wait()
201 if err == nil {
202 err = err1
203 }
204
205 if err == nil && len(errCh) > 0 {
206 return false, <-errCh
207 }
208 return true, err
209}
210
211// Inactive checks if all nodes are inactive for this builder.
212func (b *Builder) Inactive() bool {

Callers 3

runInspectFunction · 0.80
runCreateFunction · 0.80
loadNodesFunction · 0.80

Calls 5

WaitMethod · 0.95
NewPrinterFunction · 0.92
WithPrefixFunction · 0.92
BootFunction · 0.92
GoMethod · 0.65

Tested by

no test coverage detected