Skip to content

Commit

Permalink
Merge branch 'main' into doc-update-understand-the-basics
Browse files Browse the repository at this point in the history
  • Loading branch information
bdfinst authored Feb 25, 2023
2 parents 5a7bf17 + 492658e commit 8c9b7f7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/internal/packager/images/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (i *ImgConfig) PullAll() error {
for update := range progress {
switch {
case update.Error != nil && errors.Is(update.Error, io.EOF):
progressBar.Success("Pulling %d images (%s)", len(imageMap), utils.ByteFormat(float64(update.Total), 2))
progressBar.Successf("Pulling %d images (%s)", len(imageMap), utils.ByteFormat(float64(update.Total), 2))
return nil
case update.Error != nil && strings.HasPrefix(update.Error.Error(), "archive/tar: missed writing "):
// Handle potential image cache corruption with a more helpful error. See L#54 in libexec/src/archive/tar/writer.go
Expand Down
9 changes: 3 additions & 6 deletions src/pkg/message/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
package message

import (
"fmt"

"github.com/pterm/pterm"
)

Expand All @@ -17,9 +15,8 @@ type ProgressBar struct {
}

// NewProgressBar creates a new ProgressBar instance from a total value and a format.
func NewProgressBar(total int64, format string, a ...any) *ProgressBar {
func NewProgressBar(total int64, text string) *ProgressBar {
var progress *pterm.ProgressbarPrinter
text := fmt.Sprintf(" "+format, a...)
if NoProgress {
Info(text)
} else {
Expand Down Expand Up @@ -57,9 +54,9 @@ func (p *ProgressBar) Write(data []byte) (int, error) {
}

// Success marks the ProgressBar as successful in the CLI.
func (p *ProgressBar) Success(text string, a ...any) {
func (p *ProgressBar) Successf(format string, a ...any) {
p.Stop()
pterm.Success.Printfln(text, a...)
pterm.Success.Printfln(format, a...)
}

// Stop stops the ProgressBar from continuing.
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/utils/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func httpGetFile(url string, destinationFile *os.File) {
progressBar.Fatalf(err, "Unable to save the file %s", destinationFile.Name())
}

progressBar.Success(text)
progressBar.Successf("%s", text)
}

func sgetFile(url string, destinationFile *os.File, cosignKeyPath string) {
Expand Down

0 comments on commit 8c9b7f7

Please sign in to comment.