Skip to content

Commit

Permalink
Rename and change progressbar signatures to fix visual errors (#1380)
Browse files Browse the repository at this point in the history
Small fix to normalize function signatures in message/progress.go and
fix a visual error with progressbar downloads.

Fixes #1375

- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Other (security config, docs update, etc)

- [X] Test, docs, adr added or updated as needed
- [X] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow)
followed
  • Loading branch information
Racer159 committed Mar 8, 2023
1 parent f44822c commit 02f2071
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
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 02f2071

Please sign in to comment.