Skip to content

Commit

Permalink
cmd/create: Replace deprecated github.com/briandowns/spinner API
Browse files Browse the repository at this point in the history
A new API was added to github.com/briandowns/spinner 1.23.0 to deprecate
the io.Writer output in favour of a pointer to an os.File [1].  This new
API enables the spinner to automatically detect whether the output is
connected to a terminal or not, which is convenient.

Commit 944b3ac already bumped the required
github.com/briandowns/spinner version to 1.23.0, so take advantage of
that.

[1] github.com/briandowns/spinner commit 1445186377e2e283
    briandowns/spinner@1445186377e2e283
    briandowns/spinner#142

#1586
  • Loading branch information
debarshiray committed Nov 1, 2024
1 parent 38ca815 commit bb2cda1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,9 @@ func createContainer(container, image, release, authFile string, showCommandToEn
logrus.Debugf("%s", arg)
}

s := spinner.New(spinner.CharSets[9], 500*time.Millisecond)
if logLevel := logrus.GetLevel(); logLevel < logrus.DebugLevel && term.IsTerminal(os.Stdout) {
s := spinner.New(spinner.CharSets[9], 500*time.Millisecond, spinner.WithWriterFile(os.Stdout))
if logLevel := logrus.GetLevel(); logLevel < logrus.DebugLevel {
s.Prefix = fmt.Sprintf("Creating container %s: ", container)
s.Writer = os.Stdout
s.Start()
defer s.Stop()
}
Expand Down Expand Up @@ -734,10 +733,9 @@ func pullImage(image, release, authFile string) (bool, error) {

logrus.Debugf("Pulling image %s", imageFull)

if logLevel := logrus.GetLevel(); logLevel < logrus.DebugLevel && term.IsTerminal(os.Stdout) {
s := spinner.New(spinner.CharSets[9], 500*time.Millisecond)
if logLevel := logrus.GetLevel(); logLevel < logrus.DebugLevel {
s := spinner.New(spinner.CharSets[9], 500*time.Millisecond, spinner.WithWriterFile(os.Stdout))
s.Prefix = fmt.Sprintf("Pulling %s: ", imageFull)
s.Writer = os.Stdout
s.Start()
defer s.Stop()
}
Expand Down

0 comments on commit bb2cda1

Please sign in to comment.