Skip to content

Commit 8b958c8

Browse files
authored
Merge pull request #154 from giodamelio/add_command_flag
Allow passing a command to be run in the container instead of /bin/sh
2 parents a3a2a63 + 89584bf commit 8b958c8

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

cmd/ecsplorer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func Execute(args []string) {
2222
version := flags.Bool("version", false, "show the version of ecsplorer")
2323
help := flags.Bool("help", false, "help for ecsplorer")
2424
profile := flags.String("profile", "", "aws profile")
25+
cmd := flags.String("cmd", "/bin/sh", "command to execute in in the container")
2526

2627
if err := flags.Parse(args[1:]); err != nil {
2728
os.Exit(1)
@@ -35,7 +36,7 @@ func Execute(args []string) {
3536
os.Exit(0)
3637
}
3738

38-
start, err := app.CreateApplication(context.Background(), getVersion(), *profile)
39+
start, err := app.CreateApplication(context.Background(), getVersion(), *profile, cmd)
3940
if err != nil {
4041
log.Fatal(err)
4142
}

internal/app/application.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ type Page interface {
2020

2121
var (
2222
Version string
23+
Cmd *string
2324

2425
app *tview.Application
2526
pages *tview.Pages
2627
awsConfig *aws.Config
2728
)
2829

29-
func CreateApplication(ctx context.Context, version string, profile string) (start func(Handler) error, err error) {
30+
func CreateApplication(ctx context.Context, version string, profile string, cmd *string) (start func(Handler) error, err error) {
3031
cfg, err := config.LoadDefaultConfig(ctx, config.WithSharedConfigProfile(profile))
3132
if err != nil {
3233
return nil, err
@@ -35,6 +36,7 @@ func CreateApplication(ctx context.Context, version string, profile string) (sta
3536
api.SetClient(cfg)
3637

3738
Version = version
39+
Cmd = cmd
3840
awsConfig = &cfg
3941
app = tview.NewApplication()
4042
pages = tview.NewPages()

internal/handler/task_detail_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TaskDetailHandler(ctx context.Context, _ ...any) (app.Page, error) {
2929
Cluster: cluster,
3030
Task: task,
3131
Container: container,
32-
Command: "/bin/sh",
32+
Command: *app.Cmd,
3333
})
3434
if err != nil {
3535
app.ErrorModal(err)

0 commit comments

Comments
 (0)