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/pflag v1.0.6
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
go.etcd.io/bbolt v1.4.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/vbatts/tar-split v0.12.1 h1:CqKoORW7BUWBe7UL/iqTVvkTBOF8UvOMKOIZykxnnbo=
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.9.3/go.mod h1:hxS8Hz4C6ijnppDSIX6LjG8FYJSoPo9iIOcE53Zik0c=
github.com/vbauerster/mpb/v8 v8.10.0 h1:5ZYEWM4ovaZGAibjzW4PlQNb5k+JpzMqVwgNyk+K0M8=
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/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs=
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=

View File

@ -15,10 +15,10 @@ const (
iFiller
iTip
iPadding
components
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,9 @@ func (s barStyle) Lbound(bound 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
}
@ -97,7 +98,9 @@ func (s barStyle) Rbound(bound 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
}
@ -107,7 +110,9 @@ func (s barStyle) Filler(filler 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
}
@ -117,7 +122,9 @@ func (s barStyle) Refiller(refiller 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
}
@ -127,7 +134,9 @@ func (s barStyle) Padding(padding 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
}
@ -139,7 +148,9 @@ func (s barStyle) Tip(frames ...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
}
@ -154,9 +165,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]),
@ -186,34 +195,14 @@ func (s barStyle) Build() BarFiller {
}
}
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 +210,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 +245,50 @@ 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},
)
return s.flushOp(barSections{
{s.metas[iLbound], s.components[iLbound].bytes},
{s.metas[iRbound], s.components[iRbound].bytes},
{s.metas[iRefiller], refilling},
{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 {
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 {
return func(w io.Writer, p []byte) (err error) {
_, err = io.WriteString(w, fn(string(p)))
func (bb barSections) flushRev(w io.Writer) error {
err := bb[0].flush(w)
if err != nil {
return err
}
}
func defaultMeta(w io.Writer, p []byte) (err error) {
_, err = w.Write(p)
return err
ss := bb[2:]
for i := len(ss) - 1; i >= 0; i-- {
err := ss[i].flush(w)
if err != nil {
return err
}
}
return bb[1].flush(w)
}

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 },
}
ss := spinnerStyle{meta: func(s string) string { return s }}
if len(frames) != 0 {
ss.frames = frames
} else {
@ -62,12 +60,14 @@ func (s spinnerStyle) PositionRight() SpinnerStyleComposer {
}
func (s spinnerStyle) Meta(fn func(string) string) SpinnerStyleComposer {
s.meta = fn
if fn != nil && len(fn("")) != 0 {
s.meta = fn
}
return s
}
func (s spinnerStyle) Build() BarFiller {
sf := &sFiller{
sf := &spinnerFiller{
frames: s.frames,
meta: s.meta,
}
@ -88,7 +88,7 @@ func (s spinnerStyle) Build() BarFiller {
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)

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/tar/asm
github.com/vbatts/tar-split/tar/storage
# github.com/vbauerster/mpb/v8 v8.9.3
## explicit; go 1.17
# github.com/vbauerster/mpb/v8 v8.10.0
## explicit; go 1.23.0
github.com/vbauerster/mpb/v8
github.com/vbauerster/mpb/v8/cwriter
github.com/vbauerster/mpb/v8/decor