Skip to content

Commit

Permalink
Replace log.Fatal with panic
Browse files Browse the repository at this point in the history
  • Loading branch information
sestrella committed Dec 19, 2024
1 parent 497657c commit 88bd863
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
17 changes: 8 additions & 9 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"os/exec"
"strings"
Expand Down Expand Up @@ -35,36 +34,36 @@ var execCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
clusterId, err := cmd.Flags().GetString(execClusterFlag)
if err != nil {
log.Fatal(err)
panic(err)
}
serviceId, err := cmd.Flags().GetString(execServiceFlag)
if err != nil {
log.Fatal(err)
panic(err)
}
taskId, err := cmd.Flags().GetString(execTaskFlag)
if err != nil {
log.Fatal(err)
panic(err)
}
containerId, err := cmd.Flags().GetString(execContainerFlag)
if err != nil {
log.Fatal(err)
panic(err)
}
command, err := cmd.Flags().GetString(execCommandFlag)
if err != nil {
log.Fatal(err)
panic(err)
}
interactive, err := cmd.Flags().GetBool(execInteractiveFlag)
if err != nil {
log.Fatal(err)
panic(err)
}
cfg, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
log.Fatal(err)
panic(err)
}
client := ecs.NewFromConfig(cfg)
err = runExec(context.TODO(), client, cfg.Region, clusterId, serviceId, taskId, containerId, command, interactive)
if err != nil {
log.Fatal(err)
panic(err)
}
},
Aliases: []string{"ssh"},
Expand Down
12 changes: 6 additions & 6 deletions cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ var logsCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
clusterId, err := cmd.Flags().GetString(logsClusterFlag)
if err != nil {
log.Fatal(err)
panic(err)
}
serviceId, err := cmd.Flags().GetString(logsServiceFlag)
if err != nil {
log.Fatal(err)
panic(err)
}
containerId, err := cmd.Flags().GetString(logsContainerFlag)
if err != nil {
log.Fatal(err)
panic(err)
}
cfg, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
log.Fatal(err)
panic(err)
}
ecsClient := ecs.NewFromConfig(cfg)
cwlogsClient := cwlogs.NewFromConfig(cfg)
err = runLogs(context.TODO(), ecsClient, cwlogsClient, clusterId, serviceId, containerId)
if err != nil {
log.Fatal(err)
panic(err)
}
},
Aliases: []string{"tail"},
Expand Down Expand Up @@ -96,7 +96,7 @@ func runLogs(ctx context.Context, ecsClient *ecs.Client, cwlogsClient *cwlogs.Cl
fmt.Printf("%v %s\n", date, *logEvent.Message)
}
default:
log.Fatalf("Unknown event type: %s", e)
panic(fmt.Sprintf("Unknown event type: %s", e))
}
}
}
Expand Down

0 comments on commit 88bd863

Please sign in to comment.