Page MenuHomePhabricator

mediawiki-docker exec feature
Closed, ResolvedPublic

Description

Add the ability to run arbitrary commands on the mediawiki docker container to the mediawiki-docker cli, including the ability to shell into the container.

Event Timeline

Change 640291 had a related patch set uploaded (by Jeena Huneidi; owner: Jeena Huneidi):
[mediawiki/tools/cli@master] Add 'exec' feature

https://gerrit.wikimedia.org/r/640291

Change 640291 merged by jenkins-bot:
[mediawiki/tools/cli@master] Add 'exec' feature

https://gerrit.wikimedia.org/r/640291

@jeena it seems that there are issues when multiple arguments passed:

$ go run ~/go/src/gerrit.wikimedia.org/r/mediawiki/tools/cli/cmd/cli/main.go docker exec mariadb-main mysql -uroot -pmain_root_password

Error: unknown shorthand flag: 'm' in -main_root_password
Usage:
  mw docker exec [service] [command] [args] [flags]

The issue is that cobra is interpreting anything with a dash as a flag for its commands. If you use the verbose output and only try with -uroot you'll see this

$ ~/projects/cli/bin/mw docker -v2 exec mariadb-main mysql -uroot                     

/usr/local/bin/docker-compose -p mw-core exec -u root mariadb-main mysql

There's no issue with -u because it's a flag for the exec command. -p is also a flag for the exec command, but -m isn't, so it's failing there.
I'll look for a workaround.

Does cobra stop processing flags after a -- ? (Or alternatively should stuff just be quoted in the shell?)

I just tried the -- before adding my flags and it worked. I'll add some documentation to the command.

Change 645441 had a related patch set uploaded (by Jeena Huneidi; owner: Jeena Huneidi):
[mediawiki/tools/cli@master] Update Usage for exec feature

https://gerrit.wikimedia.org/r/645441

Change 645441 abandoned by Addshore:

[mediawiki/tools/cli@master] Update Usage for exec feature

Reason:

This command is gone now

https://gerrit.wikimedia.org/r/645441