mirror of
https://github.com/containers/skopeo.git
synced 2025-09-19 17:15:32 +00:00
Update the vendor of containers/common
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
11
vendor/github.com/vbauerster/mpb/v7/.travis.yml
generated
vendored
11
vendor/github.com/vbauerster/mpb/v7/.travis.yml
generated
vendored
@@ -1,11 +0,0 @@
|
||||
language: go
|
||||
arch:
|
||||
- amd64
|
||||
- ppc64le
|
||||
|
||||
go:
|
||||
- 1.14.x
|
||||
|
||||
script:
|
||||
- go test -race ./...
|
||||
- for i in _examples/*/; do go build $i/*.go || exit 1; done
|
15
vendor/github.com/vbauerster/mpb/v7/README.md
generated
vendored
15
vendor/github.com/vbauerster/mpb/v7/README.md
generated
vendored
@@ -1,8 +1,7 @@
|
||||
# Multi Progress Bar
|
||||
|
||||
[](https://pkg.go.dev/github.com/vbauerster/mpb/v7)
|
||||
[](https://travis-ci.org/vbauerster/mpb)
|
||||
[](https://goreportcard.com/report/github.com/vbauerster/mpb)
|
||||
[](https://github.com/vbauerster/mpb/actions/workflows/test.yml)
|
||||
[](https://www.paypal.me/vbauerster)
|
||||
|
||||
**mpb** is a Go lib for rendering progress bars in terminal applications.
|
||||
@@ -37,10 +36,10 @@ func main() {
|
||||
|
||||
total := 100
|
||||
name := "Single Bar:"
|
||||
// adding a single bar, which will inherit container's width
|
||||
bar := p.Add(int64(total),
|
||||
// progress bar filler with customized style
|
||||
mpb.NewBarFiller(mpb.BarStyle().Lbound("╢").Filler("▌").Tip("▌").Padding("░").Rbound("╟")),
|
||||
// create a single bar, which will inherit container's width
|
||||
bar := p.New(int64(total),
|
||||
// BarFillerBuilder with custom style
|
||||
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}),
|
||||
@@ -66,7 +65,7 @@ func main() {
|
||||
|
||||
```go
|
||||
var wg sync.WaitGroup
|
||||
// passed &wg will be accounted at p.Wait() call
|
||||
// passed wg will be accounted at p.Wait() call
|
||||
p := mpb.New(mpb.WithWaitGroup(&wg))
|
||||
total, numBars := 100, 3
|
||||
wg.Add(numBars)
|
||||
@@ -104,7 +103,7 @@ func main() {
|
||||
}
|
||||
}()
|
||||
}
|
||||
// Waiting for passed &wg and for all bars to complete and flush
|
||||
// wait for passed wg and for all bars to complete and flush
|
||||
p.Wait()
|
||||
```
|
||||
|
||||
|
93
vendor/github.com/vbauerster/mpb/v7/bar.go
generated
vendored
93
vendor/github.com/vbauerster/mpb/v7/bar.go
generated
vendored
@@ -8,6 +8,7 @@ import (
|
||||
"log"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/acarl005/stripansi"
|
||||
@@ -50,11 +51,11 @@ type bState struct {
|
||||
total int64
|
||||
current int64
|
||||
refill int64
|
||||
lastN int64
|
||||
iterated bool
|
||||
lastIncrement int64
|
||||
trimSpace bool
|
||||
completed bool
|
||||
completeFlushed bool
|
||||
aborted bool
|
||||
triggerComplete bool
|
||||
dropOnComplete bool
|
||||
noPop bool
|
||||
@@ -164,12 +165,12 @@ func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) {
|
||||
}
|
||||
|
||||
// SetTotal sets total dynamically.
|
||||
// If total is less than or equal to zero it takes progress' current value.
|
||||
// If total is negative it takes progress' current value.
|
||||
func (b *Bar) SetTotal(total int64, triggerComplete bool) {
|
||||
select {
|
||||
case b.operateState <- func(s *bState) {
|
||||
s.triggerComplete = triggerComplete
|
||||
if total <= 0 {
|
||||
if total < 0 {
|
||||
s.total = s.current
|
||||
} else {
|
||||
s.total = total
|
||||
@@ -189,8 +190,7 @@ func (b *Bar) SetTotal(total int64, triggerComplete bool) {
|
||||
func (b *Bar) SetCurrent(current int64) {
|
||||
select {
|
||||
case b.operateState <- func(s *bState) {
|
||||
s.iterated = true
|
||||
s.lastN = current - s.current
|
||||
s.lastIncrement = current - s.current
|
||||
s.current = current
|
||||
if s.triggerComplete && s.current >= s.total {
|
||||
s.current = s.total
|
||||
@@ -214,10 +214,12 @@ func (b *Bar) IncrBy(n int) {
|
||||
|
||||
// IncrInt64 increments progress by amount of n.
|
||||
func (b *Bar) IncrInt64(n int64) {
|
||||
if n <= 0 {
|
||||
return
|
||||
}
|
||||
select {
|
||||
case b.operateState <- func(s *bState) {
|
||||
s.iterated = true
|
||||
s.lastN = n
|
||||
s.lastIncrement = n
|
||||
s.current += n
|
||||
if s.triggerComplete && s.current >= s.total {
|
||||
s.current = s.total
|
||||
@@ -236,10 +238,18 @@ func (b *Bar) IncrInt64(n int64) {
|
||||
func (b *Bar) DecoratorEwmaUpdate(dur time.Duration) {
|
||||
select {
|
||||
case b.operateState <- func(s *bState) {
|
||||
ewmaIterationUpdate(false, s, dur)
|
||||
if s.lastIncrement > 0 {
|
||||
s.decoratorEwmaUpdate(dur)
|
||||
s.lastIncrement = 0
|
||||
} else {
|
||||
panic("increment required before ewma iteration update")
|
||||
}
|
||||
}:
|
||||
case <-b.done:
|
||||
ewmaIterationUpdate(true, b.cacheState, dur)
|
||||
if b.cacheState.lastIncrement > 0 {
|
||||
b.cacheState.decoratorEwmaUpdate(dur)
|
||||
b.cacheState.lastIncrement = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,9 +259,7 @@ func (b *Bar) DecoratorEwmaUpdate(dur time.Duration) {
|
||||
func (b *Bar) DecoratorAverageAdjust(start time.Time) {
|
||||
select {
|
||||
case b.operateState <- func(s *bState) {
|
||||
for _, d := range s.averageDecorators {
|
||||
d.AverageAdjust(start)
|
||||
}
|
||||
s.decoratorAverageAdjust(start)
|
||||
}:
|
||||
case <-b.done:
|
||||
}
|
||||
@@ -275,6 +283,8 @@ func (b *Bar) Abort(drop bool) {
|
||||
close(done)
|
||||
return
|
||||
}
|
||||
s.aborted = true
|
||||
b.cancel()
|
||||
// container must be run during lifetime of this inner goroutine
|
||||
// we control this by done channel declared above
|
||||
go func() {
|
||||
@@ -295,7 +305,6 @@ func (b *Bar) Abort(drop bool) {
|
||||
}
|
||||
close(done) // release hold of Abort
|
||||
}()
|
||||
b.cancel()
|
||||
}:
|
||||
// guarantee: container is alive during lifetime of this hold
|
||||
<-done
|
||||
@@ -321,10 +330,7 @@ func (b *Bar) serve(ctx context.Context, s *bState) {
|
||||
case op := <-b.operateState:
|
||||
op(s)
|
||||
case <-ctx.Done():
|
||||
// Notifying decorators about shutdown event
|
||||
for _, sl := range s.shutdownListeners {
|
||||
sl.Shutdown()
|
||||
}
|
||||
s.decoratorShutdownNotify()
|
||||
b.cacheState = s
|
||||
close(b.done)
|
||||
return
|
||||
@@ -481,6 +487,45 @@ func (s *bState) wSyncTable() [][]chan int {
|
||||
return table
|
||||
}
|
||||
|
||||
func (s bState) decoratorEwmaUpdate(dur time.Duration) {
|
||||
wg := new(sync.WaitGroup)
|
||||
wg.Add(len(s.ewmaDecorators))
|
||||
for _, d := range s.ewmaDecorators {
|
||||
d := d
|
||||
go func() {
|
||||
d.EwmaUpdate(s.lastIncrement, dur)
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func (s bState) decoratorAverageAdjust(start time.Time) {
|
||||
wg := new(sync.WaitGroup)
|
||||
wg.Add(len(s.averageDecorators))
|
||||
for _, d := range s.averageDecorators {
|
||||
d := d
|
||||
go func() {
|
||||
d.AverageAdjust(start)
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func (s bState) decoratorShutdownNotify() {
|
||||
wg := new(sync.WaitGroup)
|
||||
wg.Add(len(s.shutdownListeners))
|
||||
for _, d := range s.shutdownListeners {
|
||||
d := d
|
||||
go func() {
|
||||
d.Shutdown()
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func newStatistics(tw int, s *bState) decor.Statistics {
|
||||
return decor.Statistics{
|
||||
ID: s.id,
|
||||
@@ -489,6 +534,7 @@ func newStatistics(tw int, s *bState) decor.Statistics {
|
||||
Current: s.current,
|
||||
Refill: s.refill,
|
||||
Completed: s.completeFlushed,
|
||||
Aborted: s.aborted,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,17 +545,6 @@ func extractBaseDecorator(d decor.Decorator) decor.Decorator {
|
||||
return d
|
||||
}
|
||||
|
||||
func ewmaIterationUpdate(done bool, s *bState, dur time.Duration) {
|
||||
if !done && !s.iterated {
|
||||
panic("increment required before ewma iteration update")
|
||||
} else {
|
||||
s.iterated = false
|
||||
}
|
||||
for _, d := range s.ewmaDecorators {
|
||||
d.EwmaUpdate(s.lastN, dur)
|
||||
}
|
||||
}
|
||||
|
||||
func makePanicExtender(p interface{}) extenderFunc {
|
||||
pstr := fmt.Sprint(p)
|
||||
stack := debug.Stack()
|
||||
|
25
vendor/github.com/vbauerster/mpb/v7/bar_filler.go
generated
vendored
25
vendor/github.com/vbauerster/mpb/v7/bar_filler.go
generated
vendored
@@ -9,31 +9,42 @@ import (
|
||||
// BarFiller interface.
|
||||
// Bar (without decorators) renders itself by calling BarFiller's Fill method.
|
||||
//
|
||||
// reqWidth is requested width, set by `func WithWidth(int) ContainerOption`.
|
||||
// reqWidth is requested width set by `func WithWidth(int) ContainerOption`.
|
||||
// If not set, it defaults to terminal width.
|
||||
//
|
||||
// Default implementations can be obtained via:
|
||||
//
|
||||
// func NewBarFiller(BarStyle()) BarFiller
|
||||
// func NewBarFiller(SpinnerStyle()) BarFiller
|
||||
//
|
||||
type BarFiller interface {
|
||||
Fill(w io.Writer, reqWidth int, stat decor.Statistics)
|
||||
}
|
||||
|
||||
// BarFillerBuilder interface.
|
||||
// Default implementations are:
|
||||
//
|
||||
// BarStyle()
|
||||
// SpinnerStyle()
|
||||
// NopStyle()
|
||||
//
|
||||
type BarFillerBuilder interface {
|
||||
Build() BarFiller
|
||||
}
|
||||
|
||||
// BarFillerFunc is function type adapter to convert function into BarFiller.
|
||||
// BarFillerFunc is function type adapter to convert compatible function
|
||||
// into BarFiller interface.
|
||||
type BarFillerFunc func(w io.Writer, reqWidth int, stat decor.Statistics)
|
||||
|
||||
func (f BarFillerFunc) Fill(w io.Writer, reqWidth int, stat decor.Statistics) {
|
||||
f(w, reqWidth, stat)
|
||||
}
|
||||
|
||||
// BarFillerBuilderFunc is function type adapter to convert compatible
|
||||
// function into BarFillerBuilder interface.
|
||||
type BarFillerBuilderFunc func() BarFiller
|
||||
|
||||
func (f BarFillerBuilderFunc) Build() BarFiller {
|
||||
return f()
|
||||
}
|
||||
|
||||
// NewBarFiller constructs a BarFiller from provided BarFillerBuilder.
|
||||
// Deprecated. Prefer using `*Progress.New(...)` directly.
|
||||
func NewBarFiller(b BarFillerBuilder) BarFiller {
|
||||
return b.Build()
|
||||
}
|
||||
|
14
vendor/github.com/vbauerster/mpb/v7/bar_filler_nop.go
generated
vendored
Normal file
14
vendor/github.com/vbauerster/mpb/v7/bar_filler_nop.go
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
package mpb
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/vbauerster/mpb/v7/decor"
|
||||
)
|
||||
|
||||
// NopStyle provides BarFillerBuilder which builds NOP BarFiller.
|
||||
func NopStyle() BarFillerBuilder {
|
||||
return BarFillerBuilderFunc(func() BarFiller {
|
||||
return BarFillerFunc(func(io.Writer, int, decor.Statistics) {})
|
||||
})
|
||||
}
|
23
vendor/github.com/vbauerster/mpb/v7/bar_option.go
generated
vendored
23
vendor/github.com/vbauerster/mpb/v7/bar_option.go
generated
vendored
@@ -5,12 +5,20 @@ import (
|
||||
"io"
|
||||
|
||||
"github.com/vbauerster/mpb/v7/decor"
|
||||
"github.com/vbauerster/mpb/v7/internal"
|
||||
)
|
||||
|
||||
// BarOption is a func option to alter default behavior of a bar.
|
||||
type BarOption func(*bState)
|
||||
|
||||
func skipNil(decorators []decor.Decorator) (filtered []decor.Decorator) {
|
||||
for _, d := range decorators {
|
||||
if d != nil {
|
||||
filtered = append(filtered, d)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *bState) addDecorators(dest *[]decor.Decorator, decorators ...decor.Decorator) {
|
||||
type mergeWrapper interface {
|
||||
MergeUnwrap() []decor.Decorator
|
||||
@@ -26,14 +34,14 @@ func (s *bState) addDecorators(dest *[]decor.Decorator, decorators ...decor.Deco
|
||||
// AppendDecorators let you inject decorators to the bar's right side.
|
||||
func AppendDecorators(decorators ...decor.Decorator) BarOption {
|
||||
return func(s *bState) {
|
||||
s.addDecorators(&s.aDecorators, decorators...)
|
||||
s.addDecorators(&s.aDecorators, skipNil(decorators)...)
|
||||
}
|
||||
}
|
||||
|
||||
// PrependDecorators let you inject decorators to the bar's left side.
|
||||
func PrependDecorators(decorators ...decor.Decorator) BarOption {
|
||||
return func(s *bState) {
|
||||
s.addDecorators(&s.pDecorators, decorators...)
|
||||
s.addDecorators(&s.pDecorators, skipNil(decorators)...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,9 +146,12 @@ func BarNoPop() BarOption {
|
||||
}
|
||||
}
|
||||
|
||||
// BarOptional will invoke provided option only when pick is true.
|
||||
func BarOptional(option BarOption, pick bool) BarOption {
|
||||
return BarOptOn(option, internal.Predicate(pick))
|
||||
// BarOptional will invoke provided option only when cond is true.
|
||||
func BarOptional(option BarOption, cond bool) BarOption {
|
||||
if cond {
|
||||
return option
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// BarOptOn will invoke provided option only when higher order predicate
|
||||
|
11
vendor/github.com/vbauerster/mpb/v7/container_option.go
generated
vendored
11
vendor/github.com/vbauerster/mpb/v7/container_option.go
generated
vendored
@@ -5,8 +5,6 @@ import (
|
||||
"io/ioutil"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/vbauerster/mpb/v7/internal"
|
||||
)
|
||||
|
||||
// ContainerOption is a func option to alter default behavior of a bar
|
||||
@@ -101,9 +99,12 @@ func PopCompletedMode() ContainerOption {
|
||||
}
|
||||
}
|
||||
|
||||
// ContainerOptional will invoke provided option only when pick is true.
|
||||
func ContainerOptional(option ContainerOption, pick bool) ContainerOption {
|
||||
return ContainerOptOn(option, internal.Predicate(pick))
|
||||
// ContainerOptional will invoke provided option only when cond is true.
|
||||
func ContainerOptional(option ContainerOption, cond bool) ContainerOption {
|
||||
if cond {
|
||||
return option
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContainerOptOn will invoke provided option only when higher order
|
||||
|
1
vendor/github.com/vbauerster/mpb/v7/decor/decorator.go
generated
vendored
1
vendor/github.com/vbauerster/mpb/v7/decor/decorator.go
generated
vendored
@@ -53,6 +53,7 @@ type Statistics struct {
|
||||
Current int64
|
||||
Refill int64
|
||||
Completed bool
|
||||
Aborted bool
|
||||
}
|
||||
|
||||
// Decorator interface.
|
||||
|
3
vendor/github.com/vbauerster/mpb/v7/decor/merge.go
generated
vendored
3
vendor/github.com/vbauerster/mpb/v7/decor/merge.go
generated
vendored
@@ -17,6 +17,9 @@ import (
|
||||
// +----+--------+---------+--------+
|
||||
//
|
||||
func Merge(decorator Decorator, placeholders ...WC) Decorator {
|
||||
if decorator == nil {
|
||||
return nil
|
||||
}
|
||||
if _, ok := decorator.Sync(); !ok || len(placeholders) == 0 {
|
||||
return decorator
|
||||
}
|
||||
|
41
vendor/github.com/vbauerster/mpb/v7/decor/on_abort.go
generated
vendored
Normal file
41
vendor/github.com/vbauerster/mpb/v7/decor/on_abort.go
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
package decor
|
||||
|
||||
// OnAbort returns decorator, which wraps provided decorator with sole
|
||||
// purpose to display provided message on abort event. It has no effect
|
||||
// if bar.Abort(drop bool) is called with true argument.
|
||||
//
|
||||
// `decorator` Decorator to wrap
|
||||
//
|
||||
// `message` message to display on abort event
|
||||
//
|
||||
func OnAbort(decorator Decorator, message string) Decorator {
|
||||
if decorator == nil {
|
||||
return nil
|
||||
}
|
||||
d := &onAbortWrapper{
|
||||
Decorator: decorator,
|
||||
msg: message,
|
||||
}
|
||||
if md, ok := decorator.(*mergeDecorator); ok {
|
||||
d.Decorator, md.Decorator = md.Decorator, d
|
||||
return md
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
type onAbortWrapper struct {
|
||||
Decorator
|
||||
msg string
|
||||
}
|
||||
|
||||
func (d *onAbortWrapper) Decor(s Statistics) string {
|
||||
if s.Aborted {
|
||||
wc := d.GetConf()
|
||||
return wc.FormatMsg(d.msg)
|
||||
}
|
||||
return d.Decorator.Decor(s)
|
||||
}
|
||||
|
||||
func (d *onAbortWrapper) Base() Decorator {
|
||||
return d.Decorator
|
||||
}
|
5
vendor/github.com/vbauerster/mpb/v7/decor/on_complete.go
generated
vendored
5
vendor/github.com/vbauerster/mpb/v7/decor/on_complete.go
generated
vendored
@@ -1,6 +1,6 @@
|
||||
package decor
|
||||
|
||||
// OnComplete returns decorator, which wraps provided decorator, with
|
||||
// OnComplete returns decorator, which wraps provided decorator with
|
||||
// sole purpose to display provided message on complete event.
|
||||
//
|
||||
// `decorator` Decorator to wrap
|
||||
@@ -8,6 +8,9 @@ package decor
|
||||
// `message` message to display on complete event
|
||||
//
|
||||
func OnComplete(decorator Decorator, message string) Decorator {
|
||||
if decorator == nil {
|
||||
return nil
|
||||
}
|
||||
d := &onCompleteWrapper{
|
||||
Decorator: decorator,
|
||||
msg: message,
|
||||
|
27
vendor/github.com/vbauerster/mpb/v7/decor/on_condition.go
generated
vendored
Normal file
27
vendor/github.com/vbauerster/mpb/v7/decor/on_condition.go
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
package decor
|
||||
|
||||
// OnPredicate returns decorator if predicate evaluates to true.
|
||||
//
|
||||
// `decorator` Decorator
|
||||
//
|
||||
// `predicate` func() bool
|
||||
//
|
||||
func OnPredicate(decorator Decorator, predicate func() bool) Decorator {
|
||||
if predicate() {
|
||||
return decorator
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// OnCondition returns decorator if condition is true.
|
||||
//
|
||||
// `decorator` Decorator
|
||||
//
|
||||
// `cond` bool
|
||||
//
|
||||
func OnCondition(decorator Decorator, cond bool) Decorator {
|
||||
if cond {
|
||||
return decorator
|
||||
}
|
||||
return nil
|
||||
}
|
2
vendor/github.com/vbauerster/mpb/v7/go.mod
generated
vendored
2
vendor/github.com/vbauerster/mpb/v7/go.mod
generated
vendored
@@ -4,7 +4,7 @@ require (
|
||||
github.com/VividCortex/ewma v1.2.0
|
||||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
|
||||
github.com/mattn/go-runewidth v0.0.13
|
||||
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0
|
||||
golang.org/x/sys v0.0.0-20211214234402-4825e8c3871d
|
||||
)
|
||||
|
||||
go 1.14
|
||||
|
4
vendor/github.com/vbauerster/mpb/v7/go.sum
generated
vendored
4
vendor/github.com/vbauerster/mpb/v7/go.sum
generated
vendored
@@ -6,5 +6,5 @@ github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4
|
||||
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0 h1:xrCZDmdtoloIiooiA9q0OQb9r8HejIHYoHGhGCe1pGg=
|
||||
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211214234402-4825e8c3871d h1:1oIt9o40TWWI9FUaveVpUvBe13FNqBNVXy3ue2fcfkw=
|
||||
golang.org/x/sys v0.0.0-20211214234402-4825e8c3871d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
6
vendor/github.com/vbauerster/mpb/v7/internal/predicate.go
generated
vendored
6
vendor/github.com/vbauerster/mpb/v7/internal/predicate.go
generated
vendored
@@ -1,6 +0,0 @@
|
||||
package internal
|
||||
|
||||
// Predicate helper for internal use.
|
||||
func Predicate(pick bool) func() bool {
|
||||
return func() bool { return pick }
|
||||
}
|
18
vendor/github.com/vbauerster/mpb/v7/progress.go
generated
vendored
18
vendor/github.com/vbauerster/mpb/v7/progress.go
generated
vendored
@@ -99,17 +99,19 @@ func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress {
|
||||
return p
|
||||
}
|
||||
|
||||
// AddBar creates a bar with default bar filler. Different filler can
|
||||
// be chosen and applied via `*Progress.Add(...) *Bar` method.
|
||||
// AddBar creates a bar with default bar filler.
|
||||
func (p *Progress) AddBar(total int64, options ...BarOption) *Bar {
|
||||
return p.Add(total, NewBarFiller(BarStyle()), options...)
|
||||
return p.New(total, BarStyle(), options...)
|
||||
}
|
||||
|
||||
// AddSpinner creates a bar with default spinner filler. Different
|
||||
// filler can be chosen and applied via `*Progress.Add(...) *Bar`
|
||||
// method.
|
||||
// AddSpinner creates a bar with default spinner filler.
|
||||
func (p *Progress) AddSpinner(total int64, options ...BarOption) *Bar {
|
||||
return p.Add(total, NewBarFiller(SpinnerStyle()), options...)
|
||||
return p.New(total, SpinnerStyle(), options...)
|
||||
}
|
||||
|
||||
// New creates a bar with provided BarFillerBuilder.
|
||||
func (p *Progress) New(total int64, builder BarFillerBuilder, options ...BarOption) *Bar {
|
||||
return p.Add(total, builder.Build(), options...)
|
||||
}
|
||||
|
||||
// Add creates a bar which renders itself by provided filler.
|
||||
@@ -117,7 +119,7 @@ func (p *Progress) AddSpinner(total int64, options ...BarOption) *Bar {
|
||||
// Panics if *Progress instance is done, i.e. called after *Progress.Wait().
|
||||
func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar {
|
||||
if filler == nil {
|
||||
filler = BarFillerFunc(func(io.Writer, int, decor.Statistics) {})
|
||||
filler = NopStyle().Build()
|
||||
}
|
||||
p.bwg.Add(1)
|
||||
result := make(chan *Bar)
|
||||
|
19
vendor/github.com/vbauerster/mpb/v7/proxyreader.go
generated
vendored
19
vendor/github.com/vbauerster/mpb/v7/proxyreader.go
generated
vendored
@@ -15,7 +15,7 @@ func (x *proxyReader) Read(p []byte) (int, error) {
|
||||
n, err := x.ReadCloser.Read(p)
|
||||
x.bar.IncrBy(n)
|
||||
if err == io.EOF {
|
||||
go x.bar.SetTotal(0, true)
|
||||
go x.bar.SetTotal(-1, true)
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
@@ -30,7 +30,7 @@ func (x *proxyWriterTo) WriteTo(w io.Writer) (int64, error) {
|
||||
n, err := x.wt.WriteTo(w)
|
||||
x.bar.IncrInt64(n)
|
||||
if err == io.EOF {
|
||||
go x.bar.SetTotal(0, true)
|
||||
go x.bar.SetTotal(-1, true)
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
@@ -38,14 +38,13 @@ func (x *proxyWriterTo) WriteTo(w io.Writer) (int64, error) {
|
||||
type ewmaProxyReader struct {
|
||||
io.ReadCloser // *proxyReader
|
||||
bar *Bar
|
||||
iT time.Time
|
||||
}
|
||||
|
||||
func (x *ewmaProxyReader) Read(p []byte) (int, error) {
|
||||
start := time.Now()
|
||||
n, err := x.ReadCloser.Read(p)
|
||||
if n > 0 {
|
||||
x.bar.DecoratorEwmaUpdate(time.Since(x.iT))
|
||||
x.iT = time.Now()
|
||||
x.bar.DecoratorEwmaUpdate(time.Since(start))
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
@@ -54,14 +53,13 @@ type ewmaProxyWriterTo struct {
|
||||
io.ReadCloser // *ewmaProxyReader
|
||||
wt io.WriterTo // *proxyWriterTo
|
||||
bar *Bar
|
||||
iT time.Time
|
||||
}
|
||||
|
||||
func (x *ewmaProxyWriterTo) WriteTo(w io.Writer) (int64, error) {
|
||||
start := time.Now()
|
||||
n, err := x.wt.WriteTo(w)
|
||||
if n > 0 {
|
||||
x.bar.DecoratorEwmaUpdate(time.Since(x.iT))
|
||||
x.iT = time.Now()
|
||||
x.bar.DecoratorEwmaUpdate(time.Since(start))
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
@@ -71,10 +69,9 @@ func newProxyReader(r io.Reader, bar *Bar) io.ReadCloser {
|
||||
rc = &proxyReader{rc, bar}
|
||||
|
||||
if wt, isWriterTo := r.(io.WriterTo); bar.hasEwmaDecorators {
|
||||
now := time.Now()
|
||||
rc = &ewmaProxyReader{rc, bar, now}
|
||||
rc = &ewmaProxyReader{rc, bar}
|
||||
if isWriterTo {
|
||||
rc = &ewmaProxyWriterTo{rc, wt, bar, now}
|
||||
rc = &ewmaProxyWriterTo{rc, wt, bar}
|
||||
}
|
||||
} else if isWriterTo {
|
||||
rc = &proxyWriterTo{rc, wt, bar}
|
||||
|
Reference in New Issue
Block a user