MCPcopy Index your code
hub / github.com/coder/envbox / DefaultLogImagePullFn

Function DefaultLogImagePullFn

dockerutil/image.go:300–328  ·  view source on GitHub ↗
(log buildlog.Logger)

Source from the content-addressed store, hash-verified

298}
299
300func DefaultLogImagePullFn(log buildlog.Logger) func(ImagePullEvent) error {
301 var (
302 // Avoid spamming too frequently, the messages can come quickly
303 delayDur = time.Second * 2
304 // We use a zero-value time.Time to start since we want to log
305 // the first event we get.
306 lastLog time.Time
307 )
308 return func(e ImagePullEvent) error {
309 if e.Error != "" {
310 log.Errorf(e.Error)
311 return xerrors.Errorf("pull image: %s", e.Error)
312 }
313
314 // Not enough time has transpired, return without logging.
315 if time.Since(lastLog) < delayDur {
316 return nil
317 }
318
319 msg := e.Status
320 if e.Progress != "" {
321 msg = fmt.Sprintf("%s: %s", e.Status, e.Progress)
322 }
323 log.Info(msg)
324 lastLog = time.Now()
325
326 return nil
327 }
328}
329
330func isTLSVerificationErr(err error) bool {
331 return err != nil && strings.Contains(err.Error(), "tls: failed to verify certificate: x509: certificate signed by unknown authority")

Callers 1

runDockerCVMFunction · 0.92

Calls 2

ErrorfMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected