feat: allow choosing user on remote commands

This commit is contained in:
decentral1se 2022-03-30 11:30:36 +02:00
parent acc665f054
commit b943a8b9b1
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
1 changed files with 14 additions and 0 deletions

View File

@ -32,6 +32,14 @@ var localCmdFlag = &cli.BoolFlag{
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{
Name: "command",
Aliases: []string{"cmd"},
@ -52,6 +60,7 @@ Example:
Flags: []cli.Flag{
internal.DebugFlag,
localCmdFlag,
remoteUserFlag,
},
BashComplete: autocomplete.AppNameComplete,
Before: internal.SubCommandBefore,
@ -200,6 +209,11 @@ func runCmdRemote(app config.App, abraSh, serviceName, cmdName, cmdArgs string)
Tty: true,
}
if remoteUser != "" {
logrus.Debugf("running command with user %s", remoteUser)
execCreateOpts.User = remoteUser
}
// FIXME: avoid instantiating a new CLI
dcli, err := command.NewDockerCli()
if err != nil {