Pin gopkg.in/cheggaaa/pb.v1

Update and pin the version of gopkg.in/cheggaaa/pb.v1 that we vendor.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #79
Approved by: nalind
This commit is contained in:
Nalin Dahyabhai
2017-04-19 08:57:41 -04:00
committed by Atomic Bot
parent abf01462b0
commit 50fa09528f
5 changed files with 40 additions and 17 deletions

View File

@@ -41,7 +41,7 @@ golang.org/x/crypto/openpgp master
golang.org/x/net master
golang.org/x/sys master
golang.org/x/text master
gopkg.in/cheggaaa/pb.v1 master
gopkg.in/cheggaaa/pb.v1 v1.0.13
gopkg.in/yaml.v2 cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b
k8s.io/apimachinery master https://github.com/kubernetes/apimachinery
k8s.io/client-go master https://github.com/kubernetes/client-go

22
vendor/gopkg.in/cheggaaa/pb.v1/pb.go generated vendored
View File

@@ -13,7 +13,7 @@ import (
)
// Current version
const Version = "1.0.11"
const Version = "1.0.13"
const (
// Default refresh rate - 200ms
@@ -48,7 +48,6 @@ func New64(total int64) *ProgressBar {
ManualUpdate: false,
finish: make(chan struct{}),
currentValue: -1,
mu: new(sync.Mutex),
}
return pb.Format(FORMAT)
}
@@ -97,7 +96,7 @@ type ProgressBar struct {
prefix, postfix string
mu *sync.Mutex
mu sync.Mutex
lastPrint string
BarStart string
@@ -112,7 +111,7 @@ type ProgressBar struct {
// Start print
func (pb *ProgressBar) Start() *ProgressBar {
pb.startTime = time.Now()
pb.startValue = pb.current
pb.startValue = atomic.LoadInt64(&pb.current)
if pb.Total == 0 {
pb.ShowTimeLeft = false
pb.ShowPercent = false
@@ -222,6 +221,8 @@ func (pb *ProgressBar) Finish() {
pb.finishOnce.Do(func() {
close(pb.finish)
pb.write(atomic.LoadInt64(&pb.current))
pb.mu.Lock()
defer pb.mu.Unlock()
switch {
case pb.Output != nil:
fmt.Fprintln(pb.Output)
@@ -232,6 +233,13 @@ func (pb *ProgressBar) Finish() {
})
}
// IsFinished return boolean
func (pb *ProgressBar) IsFinished() bool {
pb.mu.Lock()
defer pb.mu.Unlock()
return pb.isFinish
}
// End print and write string 'str'
func (pb *ProgressBar) FinishPrint(str string) {
pb.Finish()
@@ -371,9 +379,10 @@ func (pb *ProgressBar) write(current int64) {
// and print!
pb.mu.Lock()
pb.lastPrint = out + end
isFinish := pb.isFinish
pb.mu.Unlock()
switch {
case pb.isFinish:
case isFinish:
return
case pb.Output != nil:
fmt.Fprint(pb.Output, "\r"+out+end)
@@ -420,7 +429,10 @@ func (pb *ProgressBar) Update() {
}
}
// String return the last bar print
func (pb *ProgressBar) String() string {
pb.mu.Lock()
defer pb.mu.Unlock()
return pb.lastPrint
}

View File

@@ -20,15 +20,19 @@ func StartPool(pbs ...*ProgressBar) (pool *Pool, err error) {
}
type Pool struct {
Output io.Writer
RefreshRate time.Duration
bars []*ProgressBar
quit chan int
finishOnce sync.Once
Output io.Writer
RefreshRate time.Duration
bars []*ProgressBar
lastBarsCount int
quit chan int
m sync.Mutex
finishOnce sync.Once
}
// Add progress bars.
func (p *Pool) Add(pbs ...*ProgressBar) {
p.m.Lock()
defer p.m.Unlock()
for _, bar := range pbs {
bar.ManualUpdate = true
bar.NotPrint = true

View File

@@ -8,13 +8,18 @@ import (
)
func (p *Pool) print(first bool) bool {
p.m.Lock()
defer p.m.Unlock()
var out string
if !first {
coords, err := getCursorPos()
if err != nil {
log.Panic(err)
}
coords.Y -= int16(len(p.bars))
coords.Y -= int16(p.lastBarsCount)
if coords.Y < 0 {
coords.Y = 0
}
coords.X = 0
err = setCursorPos(coords)
@@ -24,7 +29,7 @@ func (p *Pool) print(first bool) bool {
}
isFinished := true
for _, bar := range p.bars {
if !bar.isFinish {
if !bar.IsFinished() {
isFinished = false
}
bar.Update()
@@ -35,6 +40,6 @@ func (p *Pool) print(first bool) bool {
} else {
fmt.Print(out)
}
p.lastBarsCount = len(p.bars)
return isFinished
}

View File

@@ -5,13 +5,15 @@ package pb
import "fmt"
func (p *Pool) print(first bool) bool {
p.m.Lock()
defer p.m.Unlock()
var out string
if !first {
out = fmt.Sprintf("\033[%dA", len(p.bars))
out = fmt.Sprintf("\033[%dA", p.lastBarsCount)
}
isFinished := true
for _, bar := range p.bars {
if !bar.isFinish {
if !bar.IsFinished() {
isFinished = false
}
bar.Update()
@@ -22,6 +24,6 @@ func (p *Pool) print(first bool) bool {
} else {
fmt.Print(out)
}
p.lastBarsCount = len(p.bars)
return isFinished
}