Skip to content

Commit

Permalink
fix: set progress bar desc to shorter string
Browse files Browse the repository at this point in the history
Set the progress bar description to a shorter string. The full URL to
the kubectl binary causes the progress bar to break. Setting it to
something more meaningful like the version of kubectl currently
downloading seems like a reasonable alternative.
  • Loading branch information
justenwalker committed Jul 10, 2020
1 parent 2363f33 commit 8750c06
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/downloader/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (d *Downloder) GetKubectlBinary(version semver.Version, destination string)
}
}

return d.download(downloadURL, destination, 0755)
return d.download(fmt.Sprintf("kubectl%s%s", version, osexec.Ext), downloadURL, destination, 0755)
}

func (d *Downloder) kubectlDownloadURL(v semver.Version) (string, error) {
Expand All @@ -88,7 +88,7 @@ func (d *Downloder) kubectlDownloadURL(v semver.Version) (string, error) {
return u.String(), nil
}

func (d *Downloder) download(urlToGet, destination string, mode os.FileMode) error {
func (d *Downloder) download(desc, urlToGet, destination string, mode os.FileMode) error {
req, err := http.NewRequest("GET", urlToGet, nil)
if err != nil {
return fmt.Errorf(
Expand Down Expand Up @@ -122,11 +122,13 @@ func (d *Downloder) download(urlToGet, destination string, mode os.FileMode) err

// write progress to stderr, writing to stdout would
// break bash/zsh/shell completion
fmt.Fprintf(os.Stderr, "Downloading %s\n", urlToGet)
bar := progressbar.NewOptions(
int(resp.ContentLength),
progressbar.OptionSetDescription(urlToGet),
progressbar.OptionSetDescription(desc),
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionShowBytes(true),
progressbar.OptionSetWidth(40),
progressbar.OptionThrottle(10*time.Millisecond),
progressbar.OptionShowCount(),
progressbar.OptionOnCompletion(func() {
Expand Down

0 comments on commit 8750c06

Please sign in to comment.