Update module github.com/containers/image/v5 to v5.36.0

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
renovate[bot]
2025-07-15 21:58:37 +00:00
committed by GitHub
parent cb17dedf54
commit f17b4c9672
829 changed files with 15819 additions and 106357 deletions

View File

@@ -104,14 +104,14 @@ func main() {
p.Wait()
```
#### [Dynamic total](_examples/dynTotal/main.go)
#### [dynTotal example](_examples/dynTotal/main.go)
![dynamic total](_svg/godEMrCZmJkHYH1X9dN4Nm0U7.svg)
![dynTotal](_svg/godEMrCZmJkHYH1X9dN4Nm0U7.svg)
#### [Complex example](_examples/complex/main.go)
#### [complex example](_examples/complex/main.go)
![complex](_svg/wHzf1M7sd7B3zVa2scBMnjqRf.svg)
#### [Bytes counters](_examples/io/main.go)
#### [io example](_examples/io/main.go)
![byte counters](_svg/hIpTa3A5rQz65ssiVuRJu87X6.svg)
![io](_svg/hIpTa3A5rQz65ssiVuRJu87X6.svg)

View File

@@ -145,13 +145,7 @@ func (b *Bar) Current() int64 {
// operation for example.
func (b *Bar) SetRefill(amount int64) {
select {
case b.operateState <- func(s *bState) {
if amount < s.current {
s.refill = amount
} else {
s.refill = s.current
}
}:
case b.operateState <- func(s *bState) { s.refill = min(amount, s.current) }:
case <-b.ctx.Done():
}
}
@@ -275,10 +269,10 @@ func (b *Bar) EwmaIncrInt64(n int64, iterDur time.Duration) {
var wg sync.WaitGroup
wg.Add(len(s.ewmaDecorators))
for _, d := range s.ewmaDecorators {
d := d
// d := d // NOTE: uncomment for Go < 1.22, see /doc/faq#closures_and_goroutines
go func() {
defer wg.Done()
d.EwmaUpdate(n, iterDur)
wg.Done()
}()
}
s.current += n
@@ -304,10 +298,10 @@ func (b *Bar) EwmaSetCurrent(current int64, iterDur time.Duration) {
var wg sync.WaitGroup
wg.Add(len(s.ewmaDecorators))
for _, d := range s.ewmaDecorators {
d := d
// d := d // NOTE: uncomment for Go < 1.22, see /doc/faq#closures_and_goroutines
go func() {
defer wg.Done()
d.EwmaUpdate(n, iterDur)
wg.Done()
}()
}
s.current = current
@@ -394,13 +388,14 @@ func (b *Bar) Wait() {
}
func (b *Bar) serve(bs *bState) {
defer b.container.bwg.Done()
decoratorsOnShutdown := func(group []decor.Decorator) {
for _, d := range group {
if d, ok := unwrap(d).(decor.ShutdownListener); ok {
b.container.bwg.Add(1)
go func() {
defer b.container.bwg.Done()
d.OnShutdown()
b.container.bwg.Done()
}()
}
}
@@ -416,7 +411,6 @@ func (b *Bar) serve(bs *bState) {
bs.aborted = !bs.completed()
b.bs = bs
close(b.bsOk)
b.container.bwg.Done()
return
}
}

View File

@@ -10,15 +10,15 @@ import (
const (
iLbound = iota
iRbound
iRefiller
iFiller
iTip
iPadding
components
iRbound
iLen
)
var defaultBarStyle = [components]string{"[", "]", "+", "=", ">", "-"}
var defaultBarStyle = [iLen]string{"[", "+", "=", ">", "-", "]"}
// BarStyleComposer interface.
type BarStyleComposer interface {
@@ -44,15 +44,17 @@ type component struct {
bytes []byte
}
type flushSection struct {
meta func(io.Writer, []byte) error
type barSection struct {
meta func(string) string
bytes []byte
}
type bFiller struct {
components [components]component
meta [components]func(io.Writer, []byte) error
flush func(io.Writer, ...flushSection) error
type barSections [iLen]barSection
type barFiller struct {
components [iLen]component
metas [iLen]func(string) string
flushOp func(barSections, io.Writer) error
tip struct {
onComplete bool
count uint
@@ -61,8 +63,8 @@ type bFiller struct {
}
type barStyle struct {
style [components]string
metaFuncs [components]func(io.Writer, []byte) error
style [iLen]string
metas [iLen]func(string) string
tipFrames []string
tipOnComplete bool
rev bool
@@ -75,9 +77,6 @@ func BarStyle() BarStyleComposer {
style: defaultBarStyle,
tipFrames: []string{defaultBarStyle[iTip]},
}
for i := range bs.metaFuncs {
bs.metaFuncs[i] = defaultMeta
}
return bs
}
@@ -87,7 +86,7 @@ func (s barStyle) Lbound(bound string) BarStyleComposer {
}
func (s barStyle) LboundMeta(fn func(string) string) BarStyleComposer {
s.metaFuncs[iLbound] = makeMetaFunc(fn)
s.metas[iLbound] = fn
return s
}
@@ -97,7 +96,7 @@ func (s barStyle) Rbound(bound string) BarStyleComposer {
}
func (s barStyle) RboundMeta(fn func(string) string) BarStyleComposer {
s.metaFuncs[iRbound] = makeMetaFunc(fn)
s.metas[iRbound] = fn
return s
}
@@ -107,7 +106,7 @@ func (s barStyle) Filler(filler string) BarStyleComposer {
}
func (s barStyle) FillerMeta(fn func(string) string) BarStyleComposer {
s.metaFuncs[iFiller] = makeMetaFunc(fn)
s.metas[iFiller] = fn
return s
}
@@ -117,7 +116,7 @@ func (s barStyle) Refiller(refiller string) BarStyleComposer {
}
func (s barStyle) RefillerMeta(fn func(string) string) BarStyleComposer {
s.metaFuncs[iRefiller] = makeMetaFunc(fn)
s.metas[iRefiller] = fn
return s
}
@@ -127,7 +126,7 @@ func (s barStyle) Padding(padding string) BarStyleComposer {
}
func (s barStyle) PaddingMeta(fn func(string) string) BarStyleComposer {
s.metaFuncs[iPadding] = makeMetaFunc(fn)
s.metas[iPadding] = fn
return s
}
@@ -139,7 +138,7 @@ func (s barStyle) Tip(frames ...string) BarStyleComposer {
}
func (s barStyle) TipMeta(fn func(string) string) BarStyleComposer {
s.metaFuncs[iTip] = makeMetaFunc(fn)
s.metas[iTip] = fn
return s
}
@@ -154,9 +153,7 @@ func (s barStyle) Reverse() BarStyleComposer {
}
func (s barStyle) Build() BarFiller {
bf := &bFiller{
meta: s.metaFuncs,
}
bf := &barFiller{metas: s.metas}
bf.components[iLbound] = component{
width: runewidth.StringWidth(s.style[iLbound]),
bytes: []byte(s.style[iLbound]),
@@ -178,42 +175,22 @@ func (s barStyle) Build() BarFiller {
bytes: []byte(s.style[iPadding]),
}
bf.tip.onComplete = s.tipOnComplete
bf.tip.frames = make([]component, len(s.tipFrames))
for i, t := range s.tipFrames {
bf.tip.frames[i] = component{
bf.tip.frames = make([]component, 0, len(s.tipFrames))
for _, t := range s.tipFrames {
bf.tip.frames = append(bf.tip.frames, component{
width: runewidth.StringWidth(t),
bytes: []byte(t),
}
})
}
if s.rev {
bf.flush = func(w io.Writer, sections ...flushSection) error {
for i := len(sections) - 1; i >= 0; i-- {
if s := sections[i]; len(s.bytes) != 0 {
err := s.meta(w, s.bytes)
if err != nil {
return err
}
}
}
return nil
}
bf.flushOp = barSections.flushRev
} else {
bf.flush = func(w io.Writer, sections ...flushSection) error {
for _, s := range sections {
if len(s.bytes) != 0 {
err := s.meta(w, s.bytes)
if err != nil {
return err
}
}
}
return nil
}
bf.flushOp = barSections.flush
}
return bf
}
func (s *bFiller) Fill(w io.Writer, stat decor.Statistics) error {
func (s *barFiller) Fill(w io.Writer, stat decor.Statistics) error {
width := internal.CheckRequestedWidth(stat.RequestedWidth, stat.AvailableWidth)
// don't count brackets as progress
width -= (s.components[iLbound].width + s.components[iRbound].width)
@@ -221,15 +198,6 @@ func (s *bFiller) Fill(w io.Writer, stat decor.Statistics) error {
return nil
}
err := s.meta[iLbound](w, s.components[iLbound].bytes)
if err != nil {
return err
}
if width == 0 {
return s.meta[iRbound](w, s.components[iRbound].bytes)
}
var tip component
var refilling, filling, padding []byte
var fillCount int
@@ -265,26 +233,42 @@ func (s *bFiller) Fill(w io.Writer, stat decor.Statistics) error {
padding = append(padding, "…"...)
}
err = s.flush(w,
flushSection{s.meta[iRefiller], refilling},
flushSection{s.meta[iFiller], filling},
flushSection{s.meta[iTip], tip.bytes},
flushSection{s.meta[iPadding], padding},
)
if err != nil {
return err
}
return s.meta[iRbound](w, s.components[iRbound].bytes)
return s.flushOp(barSections{
{s.metas[iLbound], s.components[iLbound].bytes},
{s.metas[iRefiller], refilling},
{s.metas[iFiller], filling},
{s.metas[iTip], tip.bytes},
{s.metas[iPadding], padding},
{s.metas[iRbound], s.components[iRbound].bytes},
}, w)
}
func makeMetaFunc(fn func(string) string) func(io.Writer, []byte) error {
return func(w io.Writer, p []byte) (err error) {
_, err = io.WriteString(w, fn(string(p)))
return err
func (s barSection) flush(w io.Writer) (err error) {
if s.meta != nil {
_, err = io.WriteString(w, s.meta(string(s.bytes)))
} else {
_, err = w.Write(s.bytes)
}
}
func defaultMeta(w io.Writer, p []byte) (err error) {
_, err = w.Write(p)
return err
}
func (bb barSections) flush(w io.Writer) error {
for _, s := range bb {
err := s.flush(w)
if err != nil {
return err
}
}
return nil
}
func (bb barSections) flushRev(w io.Writer) error {
bb[0], bb[len(bb)-1] = bb[len(bb)-1], bb[0]
for i := len(bb) - 1; i >= 0; i-- {
err := bb[i].flush(w)
if err != nil {
return err
}
}
return nil
}

View File

@@ -24,7 +24,7 @@ type SpinnerStyleComposer interface {
Meta(func(string) string) SpinnerStyleComposer
}
type sFiller struct {
type spinnerFiller struct {
frames []string
count uint
meta func(string) string
@@ -40,9 +40,7 @@ type spinnerStyle struct {
// SpinnerStyle constructs default spinner style which can be altered via
// SpinnerStyleComposer interface.
func SpinnerStyle(frames ...string) SpinnerStyleComposer {
ss := spinnerStyle{
meta: func(s string) string { return s },
}
var ss spinnerStyle
if len(frames) != 0 {
ss.frames = frames
} else {
@@ -67,10 +65,7 @@ func (s spinnerStyle) Meta(fn func(string) string) SpinnerStyleComposer {
}
func (s spinnerStyle) Build() BarFiller {
sf := &sFiller{
frames: s.frames,
meta: s.meta,
}
sf := &spinnerFiller{frames: s.frames}
switch s.position {
case positionLeft:
sf.position = func(frame string, padWidth int) string {
@@ -85,10 +80,15 @@ func (s spinnerStyle) Build() BarFiller {
return strings.Repeat(" ", padWidth/2) + frame + strings.Repeat(" ", padWidth/2+padWidth%2)
}
}
if s.meta != nil {
sf.meta = s.meta
} else {
sf.meta = func(s string) string { return s }
}
return sf
}
func (s *sFiller) Fill(w io.Writer, stat decor.Statistics) error {
func (s *spinnerFiller) Fill(w io.Writer, stat decor.Statistics) error {
width := internal.CheckRequestedWidth(stat.RequestedWidth, stat.AvailableWidth)
frame := s.frames[s.count%uint(len(s.frames))]
frameWidth := runewidth.StringWidth(frame)

View File

@@ -86,6 +86,25 @@ func BarFillerOnComplete(message string) BarOption {
})
}
// BarFillerClearOnAbort clears bar's filler on abort event.
// It's shortcut for BarFillerOnAbort("").
func BarFillerClearOnAbort() BarOption {
return BarFillerOnAbort("")
}
// BarFillerOnAbort replaces bar's filler with message, on abort event.
func BarFillerOnAbort(message string) BarOption {
return BarFillerMiddleware(func(base BarFiller) BarFiller {
return BarFillerFunc(func(w io.Writer, st decor.Statistics) error {
if st.Aborted {
_, err := io.WriteString(w, message)
return err
}
return base.Fill(w, st)
})
})
}
// BarFillerMiddleware provides a way to augment the underlying BarFiller.
func BarFillerMiddleware(middle func(BarFiller) BarFiller) BarOption {
if middle == nil {

View File

@@ -1,3 +1,6 @@
//go:generate go tool stringer -type=SizeB1024 -trimprefix=_i
//go:generate go tool stringer -type=SizeB1000 -trimprefix=_
package decor
import (
@@ -5,9 +8,6 @@ import (
"strconv"
)
//go:generate stringer -type=SizeB1024 -trimprefix=_i
//go:generate stringer -type=SizeB1000 -trimprefix=_
var (
_ fmt.Formatter = SizeB1024(0)
_ fmt.Stringer = SizeB1024(0)

View File

@@ -41,7 +41,7 @@ func (m heapManager) run() {
var bHeap priorityQueue
var pMatrix, aMatrix map[int][]chan int
var len int
var l int
var sync bool
for req := range m {
@@ -51,7 +51,7 @@ func (m heapManager) run() {
heap.Push(&bHeap, data.bar)
sync = sync || data.sync
case h_sync:
if sync || len != bHeap.Len() {
if sync || l != bHeap.Len() {
pMatrix = make(map[int][]chan int)
aMatrix = make(map[int][]chan int)
for _, b := range bHeap {
@@ -64,7 +64,7 @@ func (m heapManager) run() {
}
}
sync = false
len = bHeap.Len()
l = bHeap.Len()
}
drop := req.data.(<-chan struct{})
syncWidth(pMatrix, drop)
@@ -106,7 +106,7 @@ func (m heapManager) run() {
}
case h_state:
ch := req.data.(chan<- bool)
ch <- sync || len != bHeap.Len()
ch <- sync || l != bHeap.Len()
case h_end:
ch := req.data.(chan<- interface{})
if ch != nil {

View File

@@ -20,18 +20,18 @@ func (pq priorityQueue) Swap(i, j int) {
}
func (pq *priorityQueue) Push(x interface{}) {
n := len(*pq)
bar := x.(*Bar)
bar.index = n
*pq = append(*pq, bar)
s := *pq
b := x.(*Bar)
b.index = len(s)
*pq = append(s, b)
}
func (pq *priorityQueue) Pop() interface{} {
old := *pq
n := len(old)
bar := old[n-1]
old[n-1] = nil // avoid memory leak
bar.index = -1 // for safety
*pq = old[:n-1]
return bar
var b *Bar
s := *pq
i := len(s) - 1
b, s[i] = s[i], nil // nil to avoid memory leak
b.index = -1 // for safety
*pq = s[:i]
return b
}

View File

@@ -355,16 +355,18 @@ func (s *pState) render(cw *cwriter.Writer) (err error) {
height = width
}
var barCount int
for b := range iter {
barCount++
go b.render(width)
}
return s.flush(cw, height, iterPop)
return s.flush(cw, height, barCount, iterPop)
}
func (s *pState) flush(cw *cwriter.Writer, height int, iter <-chan *Bar) error {
var popCount int
var rows []io.Reader
func (s *pState) flush(cw *cwriter.Writer, height, barCount int, iter <-chan *Bar) error {
var total, popCount int
rows := make([][]io.Reader, 0, barCount)
for b := range iter {
frame := <-b.frameCh
@@ -373,15 +375,16 @@ func (s *pState) flush(cw *cwriter.Writer, height int, iter <-chan *Bar) error {
b.cancel()
return frame.err // b.frameCh is buffered it's ok to return here
}
var usedRows int
var discarded int
for i := len(frame.rows) - 1; i >= 0; i-- {
if row := frame.rows[i]; len(rows) < height {
rows = append(rows, row)
usedRows++
if total < height {
total++
} else {
_, _ = io.Copy(io.Discard, row)
_, _ = io.Copy(io.Discard, frame.rows[i]) // Found IsInBounds
discarded++
}
}
rows = append(rows, frame.rows)
switch frame.shutdown {
case 1:
@@ -399,7 +402,7 @@ func (s *pState) flush(cw *cwriter.Writer, height int, iter <-chan *Bar) error {
}
case 2:
if s.popCompleted && !frame.noPop {
popCount += usedRows
popCount += len(frame.rows) - discarded
continue
}
fallthrough
@@ -409,13 +412,15 @@ func (s *pState) flush(cw *cwriter.Writer, height int, iter <-chan *Bar) error {
}
for i := len(rows) - 1; i >= 0; i-- {
_, err := cw.ReadFrom(rows[i])
if err != nil {
return err
for _, r := range rows[i] {
_, err := cw.ReadFrom(r)
if err != nil {
return err
}
}
}
return cw.Flush(len(rows) - popCount)
return cw.Flush(total - popCount)
}
func (s pState) makeBarState(total int64, filler BarFiller, options ...BarOption) *bState {