cmd/create: Start spinner earlier
Showing spinner after a lot of work on creating a toolbox is done (even though not really time consuming) does not make much sense. When a spinner is started successfully, a stop command is deferred. There's no need to stop it additionally.
This commit is contained in:
parent
a8c6fd19d8
commit
3aaa1d30f1
1 changed files with 11 additions and 13 deletions
|
@ -203,6 +203,17 @@ func createContainer(container, image, release string, showCommandToEnter bool)
|
|||
return err
|
||||
}
|
||||
|
||||
s := spinner.New(spinner.CharSets[9], 500*time.Millisecond)
|
||||
|
||||
stdoutFd := os.Stdout.Fd()
|
||||
stdoutFdInt := int(stdoutFd)
|
||||
if logLevel := logrus.GetLevel(); logLevel < logrus.DebugLevel && terminal.IsTerminal(stdoutFdInt) {
|
||||
s.Prefix = fmt.Sprintf("Creating container %s: ", container)
|
||||
s.Writer = os.Stdout
|
||||
s.Start()
|
||||
defer s.Stop()
|
||||
}
|
||||
|
||||
toolboxPath := os.Getenv("TOOLBOX_PATH")
|
||||
toolboxPathEnvArg := "TOOLBOX_PATH=" + toolboxPath
|
||||
toolboxPathMountArg := toolboxPath + ":/usr/bin/toolbox:ro"
|
||||
|
@ -458,23 +469,10 @@ func createContainer(container, image, release string, showCommandToEnter bool)
|
|||
logrus.Debugf("%s", arg)
|
||||
}
|
||||
|
||||
s := spinner.New(spinner.CharSets[9], 500*time.Millisecond)
|
||||
|
||||
stdoutFd := os.Stdout.Fd()
|
||||
stdoutFdInt := int(stdoutFd)
|
||||
if logLevel := logrus.GetLevel(); logLevel < logrus.DebugLevel && terminal.IsTerminal(stdoutFdInt) {
|
||||
s.Prefix = fmt.Sprintf("Creating container %s: ", container)
|
||||
s.Writer = os.Stdout
|
||||
s.Start()
|
||||
defer s.Stop()
|
||||
}
|
||||
|
||||
if err := shell.Run("podman", nil, nil, nil, createArgs...); err != nil {
|
||||
return fmt.Errorf("failed to create container %s", container)
|
||||
}
|
||||
|
||||
s.Stop()
|
||||
|
||||
if showCommandToEnter {
|
||||
fmt.Printf("Created container: %s\n", container)
|
||||
fmt.Printf("Enter with: %s\n", enterCommand)
|
||||
|
|
Loading…
Reference in a new issue