summaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster/mpb/v6/internal
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-03-25 10:50:01 -0700
committerGitHub <noreply@github.com>2021-03-25 10:50:01 -0700
commitdb356748738762c31a036c179d23488d7978dabf (patch)
treea01d257cba3349b47ff743b11eaa7f496bac991b /vendor/github.com/vbauerster/mpb/v6/internal
parent24581d8760691af1657c4f890d42ebd76f5e85c4 (diff)
parent4ab8a6f67eb9de0de40d478cb0cbec05b1b725c0 (diff)
downloadpodman-db356748738762c31a036c179d23488d7978dabf.tar.gz
podman-db356748738762c31a036c179d23488d7978dabf.tar.bz2
podman-db356748738762c31a036c179d23488d7978dabf.zip
Merge pull request #9781 from baude/addqemu
introduce podman machine
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v6/internal')
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/internal/percentage.go19
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/internal/predicate.go6
-rw-r--r--vendor/github.com/vbauerster/mpb/v6/internal/width.go10
3 files changed, 35 insertions, 0 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v6/internal/percentage.go b/vendor/github.com/vbauerster/mpb/v6/internal/percentage.go
new file mode 100644
index 000000000..a8ef8be12
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v6/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/v6/internal/predicate.go b/vendor/github.com/vbauerster/mpb/v6/internal/predicate.go
new file mode 100644
index 000000000..1e4dd24d9
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v6/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/v6/internal/width.go b/vendor/github.com/vbauerster/mpb/v6/internal/width.go
new file mode 100644
index 000000000..216320f24
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v6/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 <= 0 || requested >= available {
+ return available
+ }
+ return requested
+}