diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2022-01-10 13:47:12 +0100 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2022-01-10 16:25:37 +0100 |
commit | b7380a7c367246fa50b2380a99dbff39c4dc78d0 (patch) | |
tree | 5ab5bd236e3f6f0e9036287a16740b184aa3c40b /vendor/github.com/vbauerster/mpb/v7/bar_option.go | |
parent | 6ed2c639ac614b8292660fda604d3a8f6cbb42b7 (diff) | |
download | podman-b7380a7c367246fa50b2380a99dbff39c4dc78d0.tar.gz podman-b7380a7c367246fa50b2380a99dbff39c4dc78d0.tar.bz2 podman-b7380a7c367246fa50b2380a99dbff39c4dc78d0.zip |
vendor c/common
Also update the e2e pull test to account for the changes when pulling
from the dir transport. Images pulled via the dir transport are not
tagged anymore; the path is not a reliable source.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v7/bar_option.go')
-rw-r--r-- | vendor/github.com/vbauerster/mpb/v7/bar_option.go | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v7/bar_option.go b/vendor/github.com/vbauerster/mpb/v7/bar_option.go index 46b7de0bf..660e7c487 100644 --- a/vendor/github.com/vbauerster/mpb/v7/bar_option.go +++ b/vendor/github.com/vbauerster/mpb/v7/bar_option.go @@ -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 |