Skip to content

Commit 8614ebf

Browse files
author
Andrea Falzetti
committed
fix: logs
1 parent 08da29f commit 8614ebf

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

components/gitpod-cli/cmd/build.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package cmd
77
import (
88
"context"
99
"fmt"
10+
"log"
1011
"os"
1112
"os/exec"
1213
"path/filepath"
@@ -36,7 +37,7 @@ var buildCmd = &cobra.Command{
3637

3738
tmpDir, err := os.MkdirTemp("", "gp-build-*")
3839
if err != nil {
39-
utils.LogError(ctx, err, "Could not create temporary directory", client)
40+
log.Fatal("Could not create temporary directory")
4041
return
4142
}
4243
defer os.RemoveAll(tmpDir)
@@ -50,7 +51,7 @@ var buildCmd = &cobra.Command{
5051
ctx = context.Background()
5152
gitpodConfig, err := util.ParseGitpodConfig(wsInfo.CheckoutLocation)
5253
if err != nil {
53-
utils.LogError(ctx, err, "Could not parse gitpod config", client)
54+
log.Fatal("Could not parse gitpod config")
5455
return
5556
}
5657

@@ -72,14 +73,14 @@ var buildCmd = &cobra.Command{
7273
baseimage = "FROM " + img
7374
case map[interface{}]interface{}:
7475
dockerfilePath := filepath.Join(wsInfo.CheckoutLocation, img["file"].(string))
75-
fmt.Println(dockerfilePath)
76+
7677
if _, err := os.Stat(dockerfilePath); os.IsNotExist(err) {
7778
fmt.Println("Your .gitpod.yml points to a Dockerfile that doesn't exist: " + dockerfilePath)
7879
return
7980
}
8081
dockerfile, err := os.ReadFile(dockerfilePath)
8182
if err != nil {
82-
utils.LogError(ctx, err, "Could not read the Dockerfile", client)
83+
log.Fatal("Could not read the Dockerfile")
8384
return
8485
}
8586
if string(dockerfile) == "" {
@@ -105,6 +106,13 @@ var buildCmd = &cobra.Command{
105106
return
106107
}
107108

109+
err = os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(baseimage), 0644)
110+
if err != nil {
111+
fmt.Println("Could not write the temporary Dockerfile")
112+
log.Fatal(err)
113+
return
114+
}
115+
108116
tag := "temp-build-" + time.Now().Format("20060102150405")
109117

110118
dockerCmd := exec.Command("docker", "build", "-t", tag, "--progress=tty", ".")
@@ -113,25 +121,22 @@ var buildCmd = &cobra.Command{
113121
dockerCmd.Stdout = os.Stdout
114122
dockerCmd.Stderr = os.Stderr
115123

116-
err = os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(baseimage), 0644)
117-
if err != nil {
118-
utils.LogError(ctx, err, "Could not write the temporary Dockerfile", client)
119-
return
120-
}
121-
122124
go func() {
123125
<-ctx.Done()
124126
if proc := dockerCmd.Process; proc != nil {
125127
_ = proc.Kill()
126128
}
127129
}()
128130

131+
// TODO: duration
129132
err = dockerCmd.Run()
130133
if _, ok := err.(*exec.ExitError); ok {
131-
utils.LogError(ctx, err, "Workspace image build failed", client)
134+
fmt.Println("Image Build Failed")
135+
log.Fatal(err)
132136
return
133137
} else if err != nil {
134-
utils.LogError(ctx, err, "Docker error", client)
138+
fmt.Println("Docker error")
139+
log.Fatal(err)
135140
return
136141
}
137142
},

0 commit comments

Comments
 (0)