From 4f1f03d871162a451897dc42d4d2bbdc5b500a34 Mon Sep 17 00:00:00 2001 From: Matthias Diester Date: Mon, 29 Jul 2024 14:14:29 +0200 Subject: [PATCH] Add checks for progress bar updates Add check to verify that changing the max is required. Add check to avoid that current values exceeds current max. --- pkg/shp/bundle/bundle.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/shp/bundle/bundle.go b/pkg/shp/bundle/bundle.go index e8c53e7df..b8ee9bbcc 100644 --- a/pkg/shp/bundle/bundle.go +++ b/pkg/shp/bundle/bundle.go @@ -17,6 +17,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +func min(a, b int64) int64 { + if a < b { + return a + } + return b +} + // GetSourceBundleImage returns the source bundle image of the build that is // associated with the provided buildrun, an empty string if source bundle is // not used, or an error in case the build cannot be obtained @@ -98,8 +105,11 @@ func Push(ctx context.Context, io *genericclioptions.IOStreams, localDirectory s defer progress.Close() } - progress.ChangeMax64(update.Total) - _ = progress.Set64(update.Complete) + if update.Total != progress.GetMax64() { + progress.ChangeMax64(update.Total) + } + + _ = progress.Set64(min(update.Complete, update.Total)) } } }()