MCPcopy
hub / github.com/google/go-containerregistry / checkUpdates

Function checkUpdates

pkg/v1/remote/progress_test.go:432–458  ·  view source on GitHub ↗

checkUpdates checks that updates show steady progress toward a total, and don't describe errors.

(updates <-chan v1.Update)

Source from the content-addressed store, hash-verified

430// checkUpdates checks that updates show steady progress toward a total, and
431// don't describe errors.
432func checkUpdates(updates <-chan v1.Update) error {
433 var high, total int64
434 for u := range updates {
435 if u.Error != nil {
436 return u.Error
437 }
438
439 if u.Total < total {
440 return fmt.Errorf("total changed: was %d, saw %d", total, u.Total)
441 }
442
443 total = u.Total
444
445 if u.Complete < high {
446 return fmt.Errorf("saw progress revert: was high of %d, saw %d", high, u.Complete)
447 }
448 high = u.Complete
449 }
450
451 if high > total {
452 return fmt.Errorf("final progress (%d) exceeded total (%d) by %d", high, total, high-total)
453 } else if high < total {
454 return fmt.Errorf("final progress (%d) did not reach total (%d) by %d", high, total, total-high)
455 }
456
457 return nil
458}

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…