Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 834ae99

Browse files
authored
Merge pull request #67 from chris-crone/error-cleanup
Cleanup errors and fix e2e binary test
2 parents 696f2b5 + e76e668 commit 834ae99

File tree

5 files changed

+12
-23
lines changed

5 files changed

+12
-23
lines changed

cmd/helm.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cmd
22

33
import (
44
"fmt"
5-
"os"
65
"strings"
76

87
"github.com/docker/cli/cli"
@@ -20,12 +19,10 @@ var helmCmd = &cobra.Command{
2019
for _, v := range helmEnv {
2120
kv := strings.SplitN(v, "=", 2)
2221
if len(kv) != 2 {
23-
fmt.Printf("Missing '=' in setting '%s', expected KEY=VALUE\n", v)
24-
os.Exit(1)
22+
return fmt.Errorf("Missing '=' in setting '%s', expected KEY=VALUE", v)
2523
}
2624
if _, ok := d[kv[0]]; ok {
27-
fmt.Printf("Duplicate command line setting: '%s'\n", kv[0])
28-
os.Exit(1)
25+
return fmt.Errorf("Duplicate command line setting: '%s'", kv[0])
2926
}
3027
d[kv[0]] = kv[1]
3128
}

cmd/image-add.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cmd
22

33
import (
44
"fmt"
5-
"os"
65
"strings"
76

87
"github.com/docker/lunchbox/image"
@@ -19,8 +18,7 @@ var imageAddCmd = &cobra.Command{
1918
for _, v := range imageAddEnv {
2019
kv := strings.SplitN(v, "=", 2)
2120
if len(kv) != 2 {
22-
fmt.Printf("Malformed env input: '%s'\n", v)
23-
os.Exit(1)
21+
return fmt.Errorf("Malformed env input: '%s'", v)
2422
}
2523
d[kv[0]] = kv[1]
2624
}

cmd/render.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cmd
22

33
import (
44
"fmt"
5-
"os"
65
"strings"
76

87
"github.com/docker/cli/cli"
@@ -28,12 +27,10 @@ Override is provided in different ways:
2827
for _, v := range renderEnv {
2928
kv := strings.SplitN(v, "=", 2)
3029
if len(kv) != 2 {
31-
fmt.Printf("Missing '=' in setting '%s', expected KEY=VALUE\n", v)
32-
os.Exit(1)
30+
return fmt.Errorf("Missing '=' in setting '%s', expected KEY=VALUE", v)
3331
}
3432
if _, ok := d[kv[0]]; ok {
35-
fmt.Printf("Duplicate command line setting: '%s'\n", kv[0])
36-
os.Exit(1)
33+
return fmt.Errorf("Duplicate command line setting: '%s'", kv[0])
3734
}
3835
d[kv[0]] = kv[1]
3936
}
@@ -45,7 +42,7 @@ Override is provided in different ways:
4542
if err != nil {
4643
return err
4744
}
48-
fmt.Printf("%s", string(res))
45+
fmt.Print(string(res))
4946
return nil
5047
},
5148
}

e2e/binary_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func findBinary() string {
4242
"./docker-app-" + runtime.GOOS + binExt(),
4343
"./docker-app" + binExt(),
4444
"../_build/docker-app-" + runtime.GOOS + binExt(),
45-
"../_build/docker_app" + binExt(),
45+
"../_build/docker-app" + binExt(),
4646
}
4747
for _, binName := range binNames {
4848
if _, err := os.Stat(binName); err == nil {
@@ -122,7 +122,7 @@ func TestInitBinary(t *testing.T) {
122122
cmd := exec.Command(dockerApp, args...)
123123
output, err := cmd.CombinedOutput()
124124
if err != nil {
125-
fmt.Println(string(output))
125+
fmt.Println(output)
126126
}
127127
assert.NilError(t, err)
128128
meta, err := ioutil.ReadFile(filepath.Join(dirName, "metadata.yml"))

packager/registry.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ func Load(repotag string) error {
5252
cmd := exec.Command("docker", "save", "-o", file, repotag)
5353
output, err := cmd.CombinedOutput()
5454
if err != nil {
55-
fmt.Println("Error from docker save command:")
56-
fmt.Println(string(output))
57-
return err
55+
return errors.Wrapf(err, "error from docker save command: %s", string(output))
5856
}
5957
defer os.Remove(file)
6058
f, err := os.Open(file)
@@ -93,18 +91,17 @@ func Push(appname, prefix, tag string) error {
9391
cmd := exec.Command("docker", "push", prefix+appName(appname)+constants.AppExtension+":"+tag)
9492
output, err := cmd.CombinedOutput()
9593
if err != nil {
96-
fmt.Println(string(output))
94+
return errors.Wrapf(err, "error from docker push command: %s", string(output))
9795
}
98-
return err
96+
return nil
9997
}
10098

10199
// Pull pulls an app from a registry
102100
func Pull(repotag string) error {
103101
cmd := exec.Command("docker", "pull", repotag)
104102
output, err := cmd.CombinedOutput()
105103
if err != nil {
106-
fmt.Println(string(output))
107-
return err
104+
return errors.Wrapf(err, "error from docker pull command: %s", string(output))
108105
}
109106
return Load(repotag)
110107
}

0 commit comments

Comments
 (0)