feat: allow choosing user on remote commands
This commit is contained in:
parent
acc665f054
commit
b943a8b9b1
@ -32,6 +32,14 @@ var localCmdFlag = &cli.BoolFlag{
|
|||||||
Destination: &localCmd,
|
Destination: &localCmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var remoteUser string
|
||||||
|
var remoteUserFlag = &cli.StringFlag{
|
||||||
|
Name: "user, u",
|
||||||
|
Value: "",
|
||||||
|
Usage: "User to run command within a service context",
|
||||||
|
Destination: &remoteUser,
|
||||||
|
}
|
||||||
|
|
||||||
var appCmdCommand = cli.Command{
|
var appCmdCommand = cli.Command{
|
||||||
Name: "command",
|
Name: "command",
|
||||||
Aliases: []string{"cmd"},
|
Aliases: []string{"cmd"},
|
||||||
@ -52,6 +60,7 @@ Example:
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
internal.DebugFlag,
|
internal.DebugFlag,
|
||||||
localCmdFlag,
|
localCmdFlag,
|
||||||
|
remoteUserFlag,
|
||||||
},
|
},
|
||||||
BashComplete: autocomplete.AppNameComplete,
|
BashComplete: autocomplete.AppNameComplete,
|
||||||
Before: internal.SubCommandBefore,
|
Before: internal.SubCommandBefore,
|
||||||
@ -200,6 +209,11 @@ func runCmdRemote(app config.App, abraSh, serviceName, cmdName, cmdArgs string)
|
|||||||
Tty: true,
|
Tty: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if remoteUser != "" {
|
||||||
|
logrus.Debugf("running command with user %s", remoteUser)
|
||||||
|
execCreateOpts.User = remoteUser
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: avoid instantiating a new CLI
|
// FIXME: avoid instantiating a new CLI
|
||||||
dcli, err := command.NewDockerCli()
|
dcli, err := command.NewDockerCli()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user