From 922d2691cedcbae2286168e6e03cb6e46cb134d9 Mon Sep 17 00:00:00 2001 From: dbw7 Date: Mon, 8 Apr 2024 12:48:01 -0400 Subject: [PATCH] Embedded artifact registry progress bar (#357) * added progress bar to ear * updates based on feedback --- RELEASE_NOTES.md | 2 ++ pkg/combustion/registry.go | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7ac3052f..49f787d3 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,6 +4,8 @@ ## General +* Added a progress bar showing the progress of pulling images into the embedded artifact registry + ## API ### Image Definition Changes diff --git a/pkg/combustion/registry.go b/pkg/combustion/registry.go index 9bb37402..79fc8da8 100644 --- a/pkg/combustion/registry.go +++ b/pkg/combustion/registry.go @@ -9,14 +9,14 @@ import ( "slices" "strings" - "gopkg.in/yaml.v3" - + "github.com/schollz/progressbar/v3" "github.com/suse-edge/edge-image-builder/pkg/fileio" "github.com/suse-edge/edge-image-builder/pkg/image" "github.com/suse-edge/edge-image-builder/pkg/log" "github.com/suse-edge/edge-image-builder/pkg/registry" "github.com/suse-edge/edge-image-builder/pkg/template" "go.uber.org/zap" + "gopkg.in/yaml.v3" ) const ( @@ -360,7 +360,8 @@ func registryArtefactsPath(ctx *image.Context) string { } func populateRegistry(ctx *image.Context, images []string) error { - log.Audit("Populating Embedded Artifact Registry...") + bar := progressbar.Default(int64(len(images)), "Populating Embedded Artifact Registry...") + for _, i := range images { if err := addImageToHauler(ctx, i); err != nil { return fmt.Errorf("adding image to hauler: %w", err) @@ -373,6 +374,10 @@ func populateRegistry(ctx *image.Context, images []string) error { if err := generateRegistryTar(ctx, imageTarDest); err != nil { return fmt.Errorf("generating hauler store tar: %w", err) } + + if err := bar.Add(1); err != nil { + zap.S().Debugf("Error incrementing the progress bar: %s", err) + } } return nil