mirror of
https://github.com/containers/skopeo.git
synced 2025-09-23 02:48:26 +00:00
Update c/image after https://github.com/containers/image/pull/1816
... to work around some of the "unexpected EOF" failures. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
135
vendor/github.com/vbauerster/mpb/v8/container_option.go
generated
vendored
Normal file
135
vendor/github.com/vbauerster/mpb/v8/container_option.go
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
package mpb
|
||||
|
||||
import (
|
||||
"io"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ContainerOption is a func option to alter default behavior of a bar
|
||||
// container. Container term refers to a Progress struct which can
|
||||
// hold one or more Bars.
|
||||
type ContainerOption func(*pState)
|
||||
|
||||
// WithWaitGroup provides means to have a single joint point. If
|
||||
// *sync.WaitGroup is provided, you can safely call just p.Wait()
|
||||
// without calling Wait() on provided *sync.WaitGroup. Makes sense
|
||||
// when there are more than one bar to render.
|
||||
func WithWaitGroup(wg *sync.WaitGroup) ContainerOption {
|
||||
return func(s *pState) {
|
||||
s.uwg = wg
|
||||
}
|
||||
}
|
||||
|
||||
// WithWidth sets container width. If not set it defaults to terminal
|
||||
// width. A bar added to the container will inherit its width, unless
|
||||
// overridden by `func BarWidth(int) BarOption`.
|
||||
func WithWidth(width int) ContainerOption {
|
||||
return func(s *pState) {
|
||||
s.reqWidth = width
|
||||
}
|
||||
}
|
||||
|
||||
// WithRefreshRate overrides default 150ms refresh rate.
|
||||
func WithRefreshRate(d time.Duration) ContainerOption {
|
||||
return func(s *pState) {
|
||||
s.refreshRate = d
|
||||
}
|
||||
}
|
||||
|
||||
// WithManualRefresh disables internal auto refresh time.Ticker.
|
||||
// Refresh will occur upon receive value from provided ch.
|
||||
func WithManualRefresh(ch chan interface{}) ContainerOption {
|
||||
return func(s *pState) {
|
||||
s.manualRefresh = ch
|
||||
s.disableAutoRefresh = true
|
||||
}
|
||||
}
|
||||
|
||||
// WithRenderDelay delays rendering. By default rendering starts as
|
||||
// soon as bar is added, with this option it's possible to delay
|
||||
// rendering process by keeping provided chan unclosed. In other words
|
||||
// rendering will start as soon as provided chan is closed.
|
||||
func WithRenderDelay(ch <-chan struct{}) ContainerOption {
|
||||
return func(s *pState) {
|
||||
s.renderDelay = ch
|
||||
}
|
||||
}
|
||||
|
||||
// WithShutdownNotifier provided chanel will be closed, after all bars
|
||||
// have been rendered.
|
||||
func WithShutdownNotifier(ch chan struct{}) ContainerOption {
|
||||
return func(s *pState) {
|
||||
select {
|
||||
case <-ch:
|
||||
default:
|
||||
s.shutdownNotifier = ch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithOutput overrides default os.Stdout output. Setting it to nil
|
||||
// will effectively disable auto refresh rate and discard any output,
|
||||
// useful if you want to disable progress bars with little overhead.
|
||||
func WithOutput(w io.Writer) ContainerOption {
|
||||
var discarded bool
|
||||
if w == nil {
|
||||
w = io.Discard
|
||||
discarded = true
|
||||
}
|
||||
return func(s *pState) {
|
||||
s.output = w
|
||||
s.outputDiscarded = discarded
|
||||
}
|
||||
}
|
||||
|
||||
// WithDebugOutput sets debug output.
|
||||
func WithDebugOutput(w io.Writer) ContainerOption {
|
||||
if w == nil {
|
||||
w = io.Discard
|
||||
}
|
||||
return func(s *pState) {
|
||||
s.debugOut = w
|
||||
}
|
||||
}
|
||||
|
||||
// PopCompletedMode will pop completed bars to the top.
|
||||
// To stop rendering bar after it has been popped, use
|
||||
// mpb.BarRemoveOnComplete() option on that bar.
|
||||
func PopCompletedMode() ContainerOption {
|
||||
return func(s *pState) {
|
||||
s.popCompleted = true
|
||||
}
|
||||
}
|
||||
|
||||
// ContainerOptional will return provided option only when cond is true.
|
||||
func ContainerOptional(option ContainerOption, cond bool) ContainerOption {
|
||||
if cond {
|
||||
return option
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContainerOptOn will return provided option only when predicate evaluates to true.
|
||||
func ContainerOptOn(option ContainerOption, predicate func() bool) ContainerOption {
|
||||
if predicate() {
|
||||
return option
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContainerFuncOptional will call option and return its value only when cond is true.
|
||||
func ContainerFuncOptional(option func() ContainerOption, cond bool) ContainerOption {
|
||||
if cond {
|
||||
return option()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContainerFuncOptOn will call option and return its value only when predicate evaluates to true.
|
||||
func ContainerFuncOptOn(option func() ContainerOption, predicate func() bool) ContainerOption {
|
||||
if predicate() {
|
||||
return option()
|
||||
}
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user