summaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster/mpb/v7/internal
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-06-16 05:57:09 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-06-17 14:59:42 -0400
commitb6662eed3f27ac5466501b046db4f1608845af61 (patch)
tree7a4f80a77f812505a6261bc11ed8151235f903f1 /vendor/github.com/vbauerster/mpb/v7/internal
parent725b5001a17f703d95a3c88e4f58225c5290576b (diff)
downloadpodman-b6662eed3f27ac5466501b046db4f1608845af61.tar.gz
podman-b6662eed3f27ac5466501b046db4f1608845af61.tar.bz2
podman-b6662eed3f27ac5466501b046db4f1608845af61.zip
Vendor in containers/common v0.40.0
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v7/internal')
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/internal/percentage.go19
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/internal/predicate.go6
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/internal/width.go10
3 files changed, 35 insertions, 0 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v7/internal/percentage.go b/vendor/github.com/vbauerster/mpb/v7/internal/percentage.go
new file mode 100644
index 000000000..a8ef8be12
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v7/internal/percentage.go
@@ -0,0 +1,19 @@
+package internal
+
+import "math"
+
+// Percentage is a helper function, to calculate percentage.
+func Percentage(total, current int64, width int) float64 {
+ if total <= 0 {
+ return 0
+ }
+ if current >= total {
+ return float64(width)
+ }
+ return float64(int64(width)*current) / float64(total)
+}
+
+// PercentageRound same as Percentage but with math.Round.
+func PercentageRound(total, current int64, width int) float64 {
+ return math.Round(Percentage(total, current, width))
+}
diff --git a/vendor/github.com/vbauerster/mpb/v7/internal/predicate.go b/vendor/github.com/vbauerster/mpb/v7/internal/predicate.go
new file mode 100644
index 000000000..1e4dd24d9
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v7/internal/predicate.go
@@ -0,0 +1,6 @@
+package internal
+
+// Predicate helper for internal use.
+func Predicate(pick bool) func() bool {
+ return func() bool { return pick }
+}
diff --git a/vendor/github.com/vbauerster/mpb/v7/internal/width.go b/vendor/github.com/vbauerster/mpb/v7/internal/width.go
new file mode 100644
index 000000000..7677e404a
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v7/internal/width.go
@@ -0,0 +1,10 @@
+package internal
+
+// CheckRequestedWidth checks that requested width doesn't overflow
+// available width
+func CheckRequestedWidth(requested, available int) int {
+ if requested < 1 || requested >= available {
+ return available
+ }
+ return requested
+}