Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func init() {
flagRack,
flagApp,
stdcli.BoolFlag("detach", "d", "run process in the background"),
stdcli.BoolFlag("bare", "b", "run the command directly on the instance without running in a shell"),
stdcli.IntFlag("timeout", "t", "timeout"),
entrypoint,
),
Expand Down Expand Up @@ -53,6 +54,8 @@ func Run(rack sdk.Interface, c *stdcli.Context) error {
timeout = t
}

opts.Bare = options.Bool(c.Bool("bare"))

if w, h, err := c.TerminalSize(); err == nil {
opts.Height = options.Int(h)
opts.Width = options.Int(w)
Expand Down
1 change: 1 addition & 0 deletions pkg/structs/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type ProcessListOptions struct {
}

type ProcessRunOptions struct {
Bare *bool `header:"Bare" default:"false"`
Command *string `header:"Command"`
Environment map[string]string `header:"Environment"`
Height *int `header:"Height"`
Expand Down
30 changes: 24 additions & 6 deletions provider/aws/processes.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,33 @@ func (p *Provider) ProcessRun(app, service string, opts structs.ProcessRunOption
}

if opts.Command != nil {
cmd := []*string{
aws.String("sh"),
aws.String("-c"),
aws.String(*opts.Command),
}
bare := cb(opts.Bare, false)
var env []*ecs.KeyValuePair
if bare {
args, err := shellquote.Split(*opts.Command)
if err != nil {
return nil, err
}
cmd = make([]*string, len(args))
for i, a := range args {
cmd[i] = aws.String(a)
}
env = []*ecs.KeyValuePair{
{Name: aws.String("COMMAND"), Value: aws.String(*opts.Command)},
}
}

req.Overrides = &ecs.TaskOverride{
ContainerOverrides: []*ecs.ContainerOverride{
{
Name: aws.String(service),
Command: []*string{
aws.String("sh"),
aws.String("-c"),
aws.String(*opts.Command),
},
Name: aws.String(service),
Command: cmd,
Environment: env,
},
},
}
Expand Down