From 90472bafe9de3b1e66f9d3b98fe84b4167e4b38a Mon Sep 17 00:00:00 2001 From: dbw7 Date: Fri, 5 Apr 2024 13:33:55 -0400 Subject: [PATCH] added progress bar to ear --- RELEASE_NOTES.md | 2 ++ pkg/combustion/registry.go | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 93d13558..a446d4a2 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..535cc82c 100644 --- a/pkg/combustion/registry.go +++ b/pkg/combustion/registry.go @@ -9,6 +9,8 @@ import ( "slices" "strings" + "github.com/schollz/progressbar/v3" + "gopkg.in/yaml.v3" "github.com/suse-edge/edge-image-builder/pkg/fileio" @@ -360,7 +362,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 +376,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().Errorf("Error incrementing the progress bar: %s", err) + } } return nil