feat: refs #5483 network param added to run cmd

This commit is contained in:
Juan Ferrer 2024-01-28 12:33:56 +01:00
parent 89cfa65084
commit 2daf409f82
4 changed files with 15 additions and 9 deletions

View File

@ -279,7 +279,7 @@ Builds and starts local database server container. It only rebuilds the image
when dump have been modified.
```text
$ myt run [-c|--ci] [-r|--random]
$ myt run [-c|--ci] [-r|--random] [-n|--network <string>]
```
### start

View File

@ -18,13 +18,15 @@ class Run extends Command {
description: 'Build and start local database server container',
params: {
ci: 'Workaround for continuous integration system',
random: 'Whether to use a random container name or port'
network: 'Docker network to attach container to',
random: 'Whether to use a random container name and port'
}
};
static opts = {
alias: {
ci: 'c',
network: 'n',
random: 'r'
},
boolean: [
@ -104,6 +106,9 @@ class Run extends Command {
} catch (e) {}
}
if (opts.network)
Object.assign(runOptions, {network: opts.network});
const runChown = process.platform != 'linux';
Object.assign(runOptions, null, {
@ -120,9 +125,10 @@ class Run extends Command {
format: '{{json .NetworkSettings}}'
});
if (opts.ci)
dbConfig.host = netSettings.Gateway;
if (opts.ci) {
dbConfig.host = netSettings.Networks[networkName].IPAddress;
dbConfig.port = 3306;
} else
dbConfig.port = netSettings.Ports['3306/tcp'][0].HostPort;
} catch (err) {
await server.rm();

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@verdnatura/myt",
"version": "1.5.31",
"version": "1.5.32",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@verdnatura/myt",
"version": "1.5.31",
"version": "1.5.32",
"license": "GPL-3.0",
"dependencies": {
"@sqltools/formatter": "^1.2.5",

View File

@ -1,6 +1,6 @@
{
"name": "@verdnatura/myt",
"version": "1.5.31",
"version": "1.5.32",
"author": "Verdnatura Levante SL",
"description": "MySQL version control",
"license": "GPL-3.0",