Skip to content

Commit 1962009

Browse files
committed
Traslate code & comments
1 parent 0279edb commit 1962009

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

cmd/deploy.go

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@ var deployCmd = &cobra.Command{
2020
2121
Deploy from existing image:
2222
coderun deploy nginx:latest --name my-nginx
23-
coderun deploy my-app:v1.0 --name my-app --replicas 3 --cpu 500m --memory 1Gi
24-
coderun deploy my-app:latest --name web-app --http-port 8080 --env-file .env
2523
coderun deploy redis:latest --name my-redis --tcp-port 6379
26-
coderun deploy postgres:latest --name my-db --tcp-port 5432 --env-file database.env
2724
coderun deploy my-app:latest --name prod-app --replicas 2 --cpu 200m --memory 512Mi --http-port 3000 --env-file production.env
2825
2926
Build from source:
3027
coderun deploy --build . --name my-app
3128
coderun deploy --build ./my-app --name my-app --dockerfile Dockerfile.prod
3229
coderun deploy --build . --name web-app --http-port 8080 --env-file .env
33-
30+
3431
With persistent storage (automatically forces replicas to 1):
3532
coderun deploy postgres:15 --name my-postgres --tcp-port 5432 --storage-size 5Gi --storage-path /var/lib/postgresql/data
3633
coderun deploy mysql:8 --name my-mysql --tcp-port 3306 --storage-size 10Gi --storage-path /var/lib/mysql
@@ -334,10 +331,38 @@ func runDeploy(cmd *cobra.Command, args []string) {
334331

335332
if status.Status == "completed" {
336333
fmt.Printf("✅ Build completed successfully!\n")
334+
335+
// Show build logs for successful builds too
336+
fmt.Println("\n📋 Build logs:")
337+
fmt.Println("================")
338+
logs, err := apiClient.GetBuildLogs(status.ID)
339+
if err != nil {
340+
fmt.Printf("❌ Could not retrieve build logs: %v\n", err)
341+
} else if logs == "" {
342+
fmt.Println("No logs available")
343+
} else {
344+
fmt.Println(logs)
345+
}
346+
fmt.Println("================\n")
347+
337348
image = status.ImageURI
338349
break
339350
} else if status.Status == "failed" {
340351
fmt.Printf("❌ Build failed!\n")
352+
353+
// Try to get build logs to show the error
354+
fmt.Println("\n📋 Build logs:")
355+
fmt.Println("================")
356+
logs, err := apiClient.GetBuildLogs(status.ID)
357+
if err != nil {
358+
fmt.Printf("❌ Could not retrieve build logs: %v\n", err)
359+
} else if logs == "" {
360+
fmt.Println("No logs available")
361+
} else {
362+
fmt.Println(logs)
363+
}
364+
fmt.Println("================")
365+
341366
os.Exit(1)
342367
}
343368
}
@@ -414,6 +439,9 @@ func runDeploy(cmd *cobra.Command, args []string) {
414439
if deployment.TCPConnection != nil {
415440
fmt.Printf("TCP Connection: %s\n", *deployment.TCPConnection)
416441
}
442+
if deployment.URL != nil {
443+
fmt.Printf("HTTP URL: %s\n", *deployment.URL)
444+
}
417445
if len(deployment.EnvironmentVars) > 0 {
418446
fmt.Printf("Environment Variables: %d\n", len(deployment.EnvironmentVars))
419447
}

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func SetVersionInfo(version string) {
1515
var rootCmd = &cobra.Command{
1616
Use: "coderun",
1717
Short: "CodeRun Container-as-a-Service CLI",
18-
Long: `CodeRun CLI allows you to deploy and manage Docker containers
18+
Long: `CodeRun CLI allows you to deploy and manage Docker containers
1919
in a Kubernetes cluster with ease. Deploy your applications with simple commands.
2020
2121
Examples:

internal/client/builds.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,25 @@ func (c *Client) GetBuildStatus(buildID string) (*BuildResponse, error) {
9999

100100
return &buildResp, nil
101101
}
102+
103+
// GetBuildLogs gets build logs by ID
104+
func (c *Client) GetBuildLogs(buildID string) (string, error) {
105+
resp, err := c.makeRequest("GET", "/api/v1/builds/"+buildID+"/logs", nil)
106+
if err != nil {
107+
return "", err
108+
}
109+
defer resp.Body.Close()
110+
111+
if resp.StatusCode != http.StatusOK {
112+
return "", handleAPIError(resp)
113+
}
114+
115+
var logResp struct {
116+
Logs string `json:"logs"`
117+
}
118+
if err := json.NewDecoder(resp.Body).Decode(&logResp); err != nil {
119+
return "", fmt.Errorf("failed to decode build logs: %w", err)
120+
}
121+
122+
return logResp.Logs, nil
123+
}

0 commit comments

Comments
 (0)