Commit 80c93bfe authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

command/push: ctrl-C should work properly

parent cc61a7df
...@@ -4,6 +4,8 @@ import ( ...@@ -4,6 +4,8 @@ import (
"flag" "flag"
"fmt" "fmt"
"io" "io"
"os"
"os/signal"
"path/filepath" "path/filepath"
"strings" "strings"
...@@ -158,12 +160,12 @@ func (c *PushCommand) Run(args []string) int { ...@@ -158,12 +160,12 @@ func (c *PushCommand) Run(args []string) int {
} }
if len(badBuilds) > 0 { if len(badBuilds) > 0 {
c.Ui.Error(fmt.Sprintf( c.Ui.Error(fmt.Sprintf(
"Warning! One or more of the builds in this template does not\n" + "Warning! One or more of the builds in this template does not\n"+
"have an Atlas post-processor. Artifacts from this template will\n" + "have an Atlas post-processor. Artifacts from this template will\n"+
"not appear in the Atlas artifact registry.\n\n" + "not appear in the Atlas artifact registry.\n\n"+
"This is just a warning. Atlas will still build your template\n" + "This is just a warning. Atlas will still build your template\n"+
"and assume other post-processors are sending the artifacts where\n" + "and assume other post-processors are sending the artifacts where\n"+
"they need to go.\n\n" + "they need to go.\n\n"+
"Builds: %s\n\n", strings.Join(badBuilds, ", "))) "Builds: %s\n\n", strings.Join(badBuilds, ", ")))
} }
...@@ -188,10 +190,17 @@ func (c *PushCommand) Run(args []string) int { ...@@ -188,10 +190,17 @@ func (c *PushCommand) Run(args []string) int {
return 1 return 1
} }
// Make a ctrl-C channel
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, os.Interrupt)
defer signal.Stop(sigCh)
err = nil err = nil
select { select {
case err = <-uploadErrCh: case err = <-uploadErrCh:
err = fmt.Errorf("Error uploading: %s", err) err = fmt.Errorf("Error uploading: %s", err)
case <-sigCh:
err = fmt.Errorf("Push cancelled from Ctrl-C")
case <-doneCh: case <-doneCh:
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment