Skip to content

Commit

Permalink
use the inner progress bar
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 committed Sep 5, 2024
1 parent 704ff0e commit f057f8f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/internal/packager/images/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ func Push(ctx context.Context, cfg PushConfig) error {
registryURL = cfg.RegInfo.Address
)

progress := message.NewProgressBar(totalSize, fmt.Sprintf("Pushing %d images", len(toPush)))
defer progress.Close()
pushOptions := createPushOpts(cfg, progress)

err = retry.Do(func() error {
c, _ := cluster.NewCluster()
if c != nil {
Expand All @@ -69,6 +65,10 @@ func Push(ctx context.Context, cfg PushConfig) error {
}
}

progress := message.NewProgressBar(totalSize, fmt.Sprintf("Pushing %d images", len(toPush)))
defer progress.Close()
pushOptions := createPushOpts(cfg, progress)

pushImage := func(img v1.Image, name string) error {
if tunnel != nil {
return tunnel.Wrap(func() error { return crane.Push(img, name, pushOptions...) })
Expand All @@ -87,6 +87,11 @@ func Push(ctx context.Context, cfg PushConfig) error {
refTruncated := helpers.Truncate(refInfo.Reference, 55, true)
progress.Updatef(fmt.Sprintf("Pushing %s", refTruncated))

size, err := calcImgSize(img)
if err != nil {
return err
}

// If this is not a no checksum image push it for use with the Zarf agent
if !cfg.NoChecksum {
offlineNameCRC, err := transform.ImageTransformHost(registryURL, refInfo.Reference)
Expand All @@ -97,6 +102,8 @@ func Push(ctx context.Context, cfg PushConfig) error {
if err = pushImage(img, offlineNameCRC); err != nil {
return err
}

totalSize -= size
}

// To allow for other non-zarf workloads to easily see the images upload a non-checksum version
Expand All @@ -113,15 +120,15 @@ func Push(ctx context.Context, cfg PushConfig) error {
}

pushed = append(pushed, refInfo)
totalSize -= size
}
progress.Successf("Pushed %d images", len(cfg.ImageList))
return nil
}, retry.Context(ctx), retry.Attempts(uint(cfg.Retries)), retry.Delay(500*time.Millisecond))
if err != nil {
return err
}

progress.Successf("Pushed %d images", len(cfg.ImageList))

return nil
}

Expand Down

0 comments on commit f057f8f

Please sign in to comment.