fix(deps): update module github.com/containers/storage to v1.52.0

... and c/image/v5 to main

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
renovate[bot]
2024-01-19 23:01:59 +00:00
committed by Miloslav Trmač
parent 6baa928c1b
commit 58ff9fdb27
384 changed files with 16717 additions and 5937 deletions

View File

@@ -42,11 +42,9 @@ func main() {
mpb.BarStyle().Lbound("╢").Filler("▌").Tip("▌").Padding("░").Rbound("╟"),
mpb.PrependDecorators(
// display our name with one space on the right
decor.Name(name, decor.WC{W: len(name) + 1, C: decor.DidentRight}),
decor.Name(name, decor.WC{C: decor.DindentRight | decor.DextraSpace}),
// replace ETA decorator with "done" message, OnComplete event
decor.OnComplete(
decor.AverageETA(decor.ET_STYLE_GO, decor.WC{W: 4}), "done",
),
decor.OnComplete(decor.AverageETA(decor.ET_STYLE_GO), "done"),
),
mpb.AppendDecorators(decor.Percentage()),
)

View File

@@ -305,9 +305,6 @@ func (b *Bar) EwmaIncrBy(n int, iterDur time.Duration) {
// EwmaIncrInt64 increments progress by amount of n and updates EWMA based
// decorators by dur of a single iteration.
func (b *Bar) EwmaIncrInt64(n int64, iterDur time.Duration) {
if n <= 0 {
return
}
select {
case b.operateState <- func(s *bState) {
s.decoratorEwmaUpdate(n, iterDur)
@@ -429,13 +426,11 @@ func (b *Bar) render(tw int) {
return
}
}
frame := &renderFrame{
rows: rows,
shutdown: s.shutdown,
rmOnComplete: s.rmOnComplete,
noPop: s.noPop,
}
frame := &renderFrame{rows: rows}
if s.completed || s.aborted {
frame.shutdown = s.shutdown
frame.rmOnComplete = s.rmOnComplete
frame.noPop = s.noPop
// post increment makes sure OnComplete decorators are rendered
s.shutdown++
}
@@ -460,12 +455,15 @@ func (b *Bar) triggerCompletion(s *bState) {
}
func (b *Bar) tryEarlyRefresh(renderReq chan<- time.Time) {
var anyOtherRunning bool
var otherRunning int
b.container.traverseBars(func(bar *Bar) bool {
anyOtherRunning = b != bar && bar.IsRunning()
return anyOtherRunning
if b != bar && bar.IsRunning() {
otherRunning++
return false // stop traverse
}
return true // continue traverse
})
if !anyOtherRunning {
if otherRunning == 0 {
for {
select {
case renderReq <- time.Now():

View File

@@ -8,29 +8,27 @@ import (
)
const (
// DidentRight bit specifies identation direction.
// DindentRight sets indentation from right to left.
//
// |foo |b | With DidentRight
// | foo| b| Without DidentRight
DidentRight = 1 << iota
// |foo |b | DindentRight is set
// | foo| b| DindentRight is not set
DindentRight = 1 << iota
// DextraSpace bit adds extra space, makes sense with DSyncWidth only.
// When DidentRight bit set, the space will be added to the right,
// otherwise to the left.
// DextraSpace bit adds extra indentation space.
DextraSpace
// DSyncWidth bit enables same column width synchronization.
// Effective with multiple bars only.
DSyncWidth
// DSyncWidthR is shortcut for DSyncWidth|DidentRight
DSyncWidthR = DSyncWidth | DidentRight
// DSyncWidthR is shortcut for DSyncWidth|DindentRight
DSyncWidthR = DSyncWidth | DindentRight
// DSyncSpace is shortcut for DSyncWidth|DextraSpace
DSyncSpace = DSyncWidth | DextraSpace
// DSyncSpaceR is shortcut for DSyncWidth|DextraSpace|DidentRight
DSyncSpaceR = DSyncWidth | DextraSpace | DidentRight
// DSyncSpaceR is shortcut for DSyncWidth|DextraSpace|DindentRight
DSyncSpaceR = DSyncWidth | DextraSpace | DindentRight
)
// TimeStyle enum.
@@ -143,11 +141,10 @@ func (wc WC) Format(str string) (string, int) {
viewWidth := runewidth.StringWidth(str)
if wc.W > viewWidth {
viewWidth = wc.W
} else if (wc.C & DextraSpace) != 0 {
viewWidth++
}
if (wc.C & DSyncWidth) != 0 {
if (wc.C & DextraSpace) != 0 {
viewWidth++
}
wc.wsync <- viewWidth
viewWidth = <-wc.wsync
}
@@ -156,7 +153,7 @@ func (wc WC) Format(str string) (string, int) {
// Init initializes width related config.
func (wc *WC) Init() WC {
if (wc.C & DidentRight) != 0 {
if (wc.C & DindentRight) != 0 {
wc.fill = runewidth.FillRight
} else {
wc.fill = runewidth.FillLeft

View File

@@ -54,18 +54,19 @@ func EwmaETA(style TimeStyle, age float64, wcc ...WC) Decorator {
func MovingAverageETA(style TimeStyle, average ewma.MovingAverage, normalizer TimeNormalizer, wcc ...WC) Decorator {
d := &movingAverageETA{
WC: initWC(wcc...),
producer: chooseTimeProducer(style),
average: average,
normalizer: normalizer,
producer: chooseTimeProducer(style),
}
return d
}
type movingAverageETA struct {
WC
producer func(time.Duration) string
average ewma.MovingAverage
normalizer TimeNormalizer
producer func(time.Duration) string
zDur time.Duration
}
func (d *movingAverageETA) Decor(s Statistics) (string, int) {
@@ -78,11 +79,17 @@ func (d *movingAverageETA) Decor(s Statistics) (string, int) {
}
func (d *movingAverageETA) EwmaUpdate(n int64, dur time.Duration) {
durPerItem := float64(dur) / float64(n)
if math.IsInf(durPerItem, 0) || math.IsNaN(durPerItem) {
return
if n <= 0 {
d.zDur += dur
} else {
durPerItem := float64(d.zDur+dur) / float64(n)
if math.IsInf(durPerItem, 0) || math.IsNaN(durPerItem) {
d.zDur += dur
return
}
d.zDur = 0
d.average.Add(durPerItem)
}
d.average.Add(durPerItem)
}
// AverageETA decorator. It's wrapper of NewAverageETA.

View File

@@ -69,8 +69,8 @@ func EwmaSpeed(unit interface{}, format string, age float64, wcc ...WC) Decorato
func MovingAverageSpeed(unit interface{}, format string, average ewma.MovingAverage, wcc ...WC) Decorator {
d := &movingAverageSpeed{
WC: initWC(wcc...),
average: average,
producer: chooseSpeedProducer(unit, format),
average: average,
}
return d
}
@@ -79,26 +79,32 @@ type movingAverageSpeed struct {
WC
producer func(float64) string
average ewma.MovingAverage
msg string
zDur time.Duration
}
func (d *movingAverageSpeed) Decor(s Statistics) (string, int) {
if !s.Completed {
var speed float64
if v := d.average.Value(); v > 0 {
speed = 1 / v
}
d.msg = d.producer(speed * 1e9)
var str string
// ewma implementation may return 0 before accumulating certain number of samples
if v := d.average.Value(); v != 0 {
str = d.producer(1e9 / v)
} else {
str = d.producer(0)
}
return d.Format(d.msg)
return d.Format(str)
}
func (d *movingAverageSpeed) EwmaUpdate(n int64, dur time.Duration) {
durPerByte := float64(dur) / float64(n)
if math.IsInf(durPerByte, 0) || math.IsNaN(durPerByte) {
return
if n <= 0 {
d.zDur += dur
} else {
durPerByte := float64(d.zDur+dur) / float64(n)
if math.IsInf(durPerByte, 0) || math.IsNaN(durPerByte) {
d.zDur += dur
return
}
d.zDur = 0
d.average.Add(durPerByte)
}
d.average.Add(durPerByte)
}
// AverageSpeed decorator with dynamic unit measure adjustment. It's

View File

@@ -74,8 +74,8 @@ func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress {
dropS: make(chan struct{}),
dropD: make(chan struct{}),
renderReq: make(chan time.Time),
refreshRate: defaultRefreshRate,
popPriority: math.MinInt32,
refreshRate: defaultRefreshRate,
queueBars: make(map[*Bar]*Bar),
output: os.Stdout,
debugOut: io.Discard,
@@ -191,7 +191,7 @@ func (p *Progress) traverseBars(cb func(b *Bar) bool) {
select {
case p.operateState <- func(s *pState) { s.hm.iter(iter, drop) }:
for b := range iter {
if cb(b) {
if !cb(b) {
close(drop)
break
}
@@ -258,34 +258,58 @@ func (p *Progress) Shutdown() {
func (p *Progress) serve(s *pState, cw *cwriter.Writer) {
defer p.pwg.Done()
render := func() error { return s.render(cw) }
var err error
var w *cwriter.Writer
renderReq := s.renderReq
operateState := p.operateState
interceptIO := p.interceptIO
if s.delayRC != nil {
w = cwriter.New(io.Discard)
} else {
w, cw = cw, nil
}
for {
select {
case op := <-p.operateState:
case <-s.delayRC:
w, cw = cw, nil
s.delayRC = nil
case op := <-operateState:
op(s)
case fn := <-p.interceptIO:
fn(cw)
case <-s.renderReq:
e := render()
if e != nil {
case fn := <-interceptIO:
fn(w)
case <-renderReq:
err = s.render(w)
if err != nil {
// (*pState).(autoRefreshListener|manualRefreshListener) may block
// if not launching following short lived goroutine
go func() {
for {
select {
case <-s.renderReq:
case <-p.done:
return
}
}
}()
p.cancel() // cancel all bars
render = func() error { return nil }
err = e
renderReq = nil
operateState = nil
interceptIO = nil
}
case <-p.done:
update := make(chan bool)
for s.autoRefresh && err == nil {
s.hm.state(update)
if <-update {
err = render()
} else {
break
}
}
if err != nil {
_, _ = fmt.Fprintln(s.debugOut, err.Error())
} else if s.autoRefresh {
update := make(chan bool)
for i := 0; i == 0 || <-update; i++ {
if err := s.render(w); err != nil {
_, _ = fmt.Fprintln(s.debugOut, err.Error())
break
}
s.hm.state(update)
}
}
s.hm.end(s.shutdownNotifier)
return
@@ -293,10 +317,7 @@ func (p *Progress) serve(s *pState, cw *cwriter.Writer) {
}
}
func (s pState) autoRefreshListener(done chan struct{}) {
if s.delayRC != nil {
<-s.delayRC
}
func (s *pState) autoRefreshListener(done chan struct{}) {
ticker := time.NewTicker(s.refreshRate)
defer ticker.Stop()
for {
@@ -310,7 +331,7 @@ func (s pState) autoRefreshListener(done chan struct{}) {
}
}
func (s pState) manualRefreshListener(done chan struct{}) {
func (s *pState) manualRefreshListener(done chan struct{}) {
for {
select {
case x := <-s.manualRC:
@@ -342,9 +363,9 @@ func (s *pState) render(cw *cwriter.Writer) (err error) {
if s.reqWidth > 0 {
width = s.reqWidth
} else {
width = 100
width = 80
}
height = 100
height = width
}
for b := range iter {
@@ -420,7 +441,7 @@ func (s *pState) flush(cw *cwriter.Writer, height int) error {
return cw.Flush(len(rows) - popCount)
}
func (s pState) push(wg *sync.WaitGroup, b *Bar, sync bool) {
func (s *pState) push(wg *sync.WaitGroup, b *Bar, sync bool) {
s.hm.push(b, sync)
wg.Done()
}