summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorThomas <slashdevsda@users.noreply.github.com>2018-11-27 03:42:01 +0100
committerAlex Goodman <wagoodman@users.noreply.github.com>2018-11-26 21:42:01 -0500
commit6a32573d89a379a634310e40b24c13e4fbdf76e1 (patch)
treec95a42494bad3becddabef2ff18fa121adcc9a54 /cmd
parentd9ec426300be6c96bab5f2299ff4a68bece79ba4 (diff)
Properly exits when UI is not instanciated (#91)
Calls `util.Cleanup` - during fatal errors while interacting with docker - after `rootCmd` successful execution
Diffstat (limited to 'cmd')
-rw-r--r--cmd/build.go3
-rw-r--r--cmd/root.go1
2 files changed, 4 insertions, 0 deletions
diff --git a/cmd/build.go b/cmd/build.go
index 81b6069..13089c1 100644
--- a/cmd/build.go
+++ b/cmd/build.go
@@ -27,6 +27,7 @@ func doBuild(cmd *cobra.Command, args []string) {
defer utils.Cleanup()
iidfile, err := ioutil.TempFile("/tmp", "dive.*.iid")
if err != nil {
+ utils.Cleanup()
log.Fatal(err)
}
defer os.Remove(iidfile.Name())
@@ -34,11 +35,13 @@ func doBuild(cmd *cobra.Command, args []string) {
allArgs := append([]string{"--iidfile", iidfile.Name()}, args...)
err = utils.RunDockerCmd("build", allArgs...)
if err != nil {
+ utils.Cleanup()
log.Fatal(err)
}
imageId, err := ioutil.ReadFile(iidfile.Name())
if err != nil {
+ utils.Cleanup()
log.Fatal(err)
}
diff --git a/cmd/root.go b/cmd/root.go
index 3cf10bb..5e27ac6 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -31,6 +31,7 @@ func Execute() {
fmt.Println(err)
utils.Exit(1)
}
+ utils.Cleanup()
}
func init() {