Merge pull request #26046 from containers/renovate/github.com-vbauerster-mpb-v8-8.x

fix(deps): update module github.com/vbauerster/mpb/v8 to v8.10.0
This commit is contained in:
openshift-merge-bot[bot]
2025-05-02 11:14:46 +00:00
committed by GitHub
7 changed files with 107 additions and 84 deletions

2
go.mod
View File

@ -65,7 +65,7 @@ require (
github.com/spf13/cobra v1.9.1 github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.6 github.com/spf13/pflag v1.0.6
github.com/stretchr/testify v1.10.0 github.com/stretchr/testify v1.10.0
github.com/vbauerster/mpb/v8 v8.9.3 github.com/vbauerster/mpb/v8 v8.10.0
github.com/vishvananda/netlink v1.3.1-0.20250221194427-0af32151e72b github.com/vishvananda/netlink v1.3.1-0.20250221194427-0af32151e72b
go.etcd.io/bbolt v1.4.0 go.etcd.io/bbolt v1.4.0
golang.org/x/crypto v0.37.0 golang.org/x/crypto v0.37.0

4
go.sum
View File

@ -480,8 +480,8 @@ github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/vbatts/tar-split v0.12.1 h1:CqKoORW7BUWBe7UL/iqTVvkTBOF8UvOMKOIZykxnnbo= github.com/vbatts/tar-split v0.12.1 h1:CqKoORW7BUWBe7UL/iqTVvkTBOF8UvOMKOIZykxnnbo=
github.com/vbatts/tar-split v0.12.1/go.mod h1:eF6B6i6ftWQcDqEn3/iGFRFRo8cBIMSJVOpnNdfTMFA= github.com/vbatts/tar-split v0.12.1/go.mod h1:eF6B6i6ftWQcDqEn3/iGFRFRo8cBIMSJVOpnNdfTMFA=
github.com/vbauerster/mpb/v8 v8.9.3 h1:PnMeF+sMvYv9u23l6DO6Q3+Mdj408mjLRXIzmUmU2Z8= github.com/vbauerster/mpb/v8 v8.10.0 h1:5ZYEWM4ovaZGAibjzW4PlQNb5k+JpzMqVwgNyk+K0M8=
github.com/vbauerster/mpb/v8 v8.9.3/go.mod h1:hxS8Hz4C6ijnppDSIX6LjG8FYJSoPo9iIOcE53Zik0c= github.com/vbauerster/mpb/v8 v8.10.0/go.mod h1:DYPFebxSahB+f7tuEUGauLQ7w8ij3wMr4clsVuJCV4I=
github.com/vishvananda/netlink v1.3.1-0.20250221194427-0af32151e72b h1:hYWtmuzlR0jpWu+ljWfPMi7oNiZ9x/D3GbBqgZTOhyI= github.com/vishvananda/netlink v1.3.1-0.20250221194427-0af32151e72b h1:hYWtmuzlR0jpWu+ljWfPMi7oNiZ9x/D3GbBqgZTOhyI=
github.com/vishvananda/netlink v1.3.1-0.20250221194427-0af32151e72b/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= github.com/vishvananda/netlink v1.3.1-0.20250221194427-0af32151e72b/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs=
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=

View File

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

View File

@ -24,7 +24,7 @@ type SpinnerStyleComposer interface {
Meta(func(string) string) SpinnerStyleComposer Meta(func(string) string) SpinnerStyleComposer
} }
type sFiller struct { type spinnerFiller struct {
frames []string frames []string
count uint count uint
meta func(string) string meta func(string) string
@ -40,9 +40,7 @@ type spinnerStyle struct {
// SpinnerStyle constructs default spinner style which can be altered via // SpinnerStyle constructs default spinner style which can be altered via
// SpinnerStyleComposer interface. // SpinnerStyleComposer interface.
func SpinnerStyle(frames ...string) SpinnerStyleComposer { func SpinnerStyle(frames ...string) SpinnerStyleComposer {
ss := spinnerStyle{ ss := spinnerStyle{meta: func(s string) string { return s }}
meta: func(s string) string { return s },
}
if len(frames) != 0 { if len(frames) != 0 {
ss.frames = frames ss.frames = frames
} else { } else {
@ -62,12 +60,14 @@ func (s spinnerStyle) PositionRight() SpinnerStyleComposer {
} }
func (s spinnerStyle) Meta(fn func(string) string) SpinnerStyleComposer { func (s spinnerStyle) Meta(fn func(string) string) SpinnerStyleComposer {
s.meta = fn if fn != nil && len(fn("")) != 0 {
s.meta = fn
}
return s return s
} }
func (s spinnerStyle) Build() BarFiller { func (s spinnerStyle) Build() BarFiller {
sf := &sFiller{ sf := &spinnerFiller{
frames: s.frames, frames: s.frames,
meta: s.meta, meta: s.meta,
} }
@ -88,7 +88,7 @@ func (s spinnerStyle) Build() BarFiller {
return sf 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) width := internal.CheckRequestedWidth(stat.RequestedWidth, stat.AvailableWidth)
frame := s.frames[s.count%uint(len(s.frames))] frame := s.frames[s.count%uint(len(s.frames))]
frameWidth := runewidth.StringWidth(frame) 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. // BarFillerMiddleware provides a way to augment the underlying BarFiller.
func BarFillerMiddleware(middle func(BarFiller) BarFiller) BarOption { func BarFillerMiddleware(middle func(BarFiller) BarFiller) BarOption {
if middle == nil { 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 package decor
import ( import (
@ -5,9 +8,6 @@ import (
"strconv" "strconv"
) )
//go:generate stringer -type=SizeB1024 -trimprefix=_i
//go:generate stringer -type=SizeB1000 -trimprefix=_
var ( var (
_ fmt.Formatter = SizeB1024(0) _ fmt.Formatter = SizeB1024(0)
_ fmt.Stringer = SizeB1024(0) _ fmt.Stringer = SizeB1024(0)

4
vendor/modules.txt vendored
View File

@ -990,8 +990,8 @@ github.com/ulikunitz/xz/lzma
github.com/vbatts/tar-split/archive/tar github.com/vbatts/tar-split/archive/tar
github.com/vbatts/tar-split/tar/asm github.com/vbatts/tar-split/tar/asm
github.com/vbatts/tar-split/tar/storage github.com/vbatts/tar-split/tar/storage
# github.com/vbauerster/mpb/v8 v8.9.3 # github.com/vbauerster/mpb/v8 v8.10.0
## explicit; go 1.17 ## explicit; go 1.23.0
github.com/vbauerster/mpb/v8 github.com/vbauerster/mpb/v8
github.com/vbauerster/mpb/v8/cwriter github.com/vbauerster/mpb/v8/cwriter
github.com/vbauerster/mpb/v8/decor github.com/vbauerster/mpb/v8/decor