refactored command groups, migrations:make only available in dev/test
This commit is contained in:
parent
bb1a16988d
commit
17e70f14a2
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"name": "24unix/bindapi",
|
"name": "tracer/bindapi",
|
||||||
"description": "manage Bind9 DNS server via REST API",
|
"description": "manage Bind9 client zones for KeyHelp",
|
||||||
"version": "1.0.9",
|
"version": "1.0.9",
|
||||||
"build_number": "375",
|
"build_number": "376",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Micha Espey",
|
"name": "Micha Espey",
|
||||||
|
|
|
@ -63,14 +63,12 @@ class CLIController
|
||||||
{
|
{
|
||||||
$this->baseDir = dirname(path: __DIR__, levels: 2) . '/';
|
$this->baseDir = dirname(path: __DIR__, levels: 2) . '/';
|
||||||
|
|
||||||
$this->commandGroupContainer = (new CommandGroupContainer())
|
$apikeyGroup = (new CommandGroup(name: 'apikeys', description: 'API keys to access this bindAPI'))
|
||||||
->addCommandGroup(commandGroup: (new CommandGroup(name: 'apikeys', description: 'API keys to access this bindAPI'))
|
|
||||||
->addCommand(command: new Command(
|
->addCommand(command: new Command(
|
||||||
name: 'list',
|
name: 'list',
|
||||||
callback: function () {
|
callback: function () {
|
||||||
$this->apikeysList();
|
$this->apikeysList();
|
||||||
}
|
})
|
||||||
)
|
|
||||||
)
|
)
|
||||||
->addCommand(command: new Command(
|
->addCommand(command: new Command(
|
||||||
name: 'create',
|
name: 'create',
|
||||||
|
@ -91,14 +89,120 @@ class CLIController
|
||||||
callback: function () {
|
callback: function () {
|
||||||
$this->apikeysDelete();
|
$this->apikeysDelete();
|
||||||
},
|
},
|
||||||
mandatoryParameters: ['ID'])))
|
mandatoryParameters: ['ID']
|
||||||
->addCommandGroup(commandGroup: (new CommandGroup(name: 'cron', description: 'Run zone file maintenance'))
|
));
|
||||||
|
$cronGroup = (new CommandGroup(name: 'cron', description: 'Run zone file maintenance'))
|
||||||
->addCommand(command: new Command(
|
->addCommand(command: new Command(
|
||||||
name: 'run',
|
name: 'run',
|
||||||
callback: function () {
|
callback: function () {
|
||||||
$this->cronRun();
|
$this->cronRun();
|
||||||
})))
|
}));
|
||||||
->addCommandGroup(commandGroup: (new CommandGroup(name: 'check', description: 'health checks the system can perform'))
|
$panelsGroup = (new CommandGroup(name: 'panels', description: 'all KeyHelp systems configured'))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'list',
|
||||||
|
callback: function () {
|
||||||
|
$this->panelsList();
|
||||||
|
}))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'create',
|
||||||
|
callback: function () {
|
||||||
|
$this->panelsCreate();
|
||||||
|
},
|
||||||
|
mandatoryParameters: ['name'],
|
||||||
|
optionalParameters: ['A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>', 'self=<yes|no>']))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'update',
|
||||||
|
callback: function () {
|
||||||
|
$this->panelsUpdate();
|
||||||
|
},
|
||||||
|
mandatoryParameters: ['ID'],
|
||||||
|
optionalParameters: ['name=<name>', 'A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>', 'self=<yes|no>']))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'delete',
|
||||||
|
callback: function () {
|
||||||
|
$this->panelsDelete();
|
||||||
|
},
|
||||||
|
mandatoryParameters: ['ID']))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'apiping',
|
||||||
|
callback: function () {
|
||||||
|
$this->apiPing(type: 'panel');
|
||||||
|
},
|
||||||
|
optionalParameters: ['ID']));
|
||||||
|
$domainsGroup = (new CommandGroup(name: 'domains', description: 'configured domains'))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'list',
|
||||||
|
callback: function () {
|
||||||
|
$this->domainsList();
|
||||||
|
}))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'update',
|
||||||
|
callback: function () {
|
||||||
|
$this->domainsUpdate();
|
||||||
|
},
|
||||||
|
// mandatoryParameters: ['name'],
|
||||||
|
// optionalParameters: ['A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>'])))
|
||||||
|
description: 'Update zone files'));
|
||||||
|
$nameserversGroup = (new CommandGroup(name: 'nameservers', description: 'available nameservers'))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'list',
|
||||||
|
callback: function () {
|
||||||
|
$this->nameserversList();
|
||||||
|
}))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'create',
|
||||||
|
callback: function () {
|
||||||
|
$this->nameserversCreate();
|
||||||
|
},
|
||||||
|
mandatoryParameters: ['name'],
|
||||||
|
optionalParameters: ['A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>']))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'update',
|
||||||
|
callback: function () {
|
||||||
|
$this->nameserversUpdate();
|
||||||
|
},
|
||||||
|
mandatoryParameters: ['ID'],
|
||||||
|
optionalParameters: ['name=<name>', 'A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>']))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'delete',
|
||||||
|
callback: function () {
|
||||||
|
$this->nameserversDelete();
|
||||||
|
},
|
||||||
|
mandatoryParameters: ['ID']))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'apiping',
|
||||||
|
callback: function () {
|
||||||
|
$this->apiPing(type: 'nameserver');
|
||||||
|
},
|
||||||
|
optionalParameters: ['ID']));
|
||||||
|
$dyndnsGroup = (new CommandGroup(name: 'dyndns', description: 'handle DynDNS entries'))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'list',
|
||||||
|
callback: function () {
|
||||||
|
$this->dynDnsList();
|
||||||
|
}))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'create',
|
||||||
|
callback: function () {
|
||||||
|
$this->dynDnsCreate();
|
||||||
|
},
|
||||||
|
mandatoryParameters: ['hostname.example.com', 'password'],
|
||||||
|
optionalParameters: ['A=<IPv4>', 'AAAA=<IPv6>'],
|
||||||
|
description: 'FQDN within a domain where this server is master'))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'update',
|
||||||
|
callback: function () {
|
||||||
|
$this->dynDnyUpdate();
|
||||||
|
},
|
||||||
|
mandatoryParameters: ['hostname.example.com',],
|
||||||
|
optionalParameters: ['password=<password>', 'A=<IPv4>', 'AAAA=<IPv6>']))
|
||||||
|
->addCommand(command: new Command(
|
||||||
|
name: 'delete',
|
||||||
|
callback: function () {
|
||||||
|
$this->dynDnsDelete();
|
||||||
|
},
|
||||||
|
mandatoryParameters: ['ID']));
|
||||||
|
$checkGroup = (new CommandGroup(name: 'check', description: 'health checks the system can perform'))
|
||||||
->addCommand(command: new Command(
|
->addCommand(command: new Command(
|
||||||
name: 'cache',
|
name: 'cache',
|
||||||
callback: function () {
|
callback: function () {
|
||||||
|
@ -170,113 +274,8 @@ class CLIController
|
||||||
$this->checkVersion();
|
$this->checkVersion();
|
||||||
},
|
},
|
||||||
optionalParameters: ['update'],
|
optionalParameters: ['update'],
|
||||||
description: 'Read or set the bindApi version in the database')))
|
description: 'Read or set the bindApi version in the database'));
|
||||||
->addCommandGroup(commandGroup: (new CommandGroup(name: 'panels', description: 'all KeyHelp systems configured'))
|
$migrationsGroup = (new CommandGroup(name: 'migrations', description: 'maintain database migrations'))
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'list',
|
|
||||||
callback: function () {
|
|
||||||
$this->panelsList();
|
|
||||||
}))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'create',
|
|
||||||
callback: function () {
|
|
||||||
$this->panelsCreate();
|
|
||||||
},
|
|
||||||
mandatoryParameters: ['name'],
|
|
||||||
optionalParameters: ['A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>', 'self=<yes|no>']))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'update',
|
|
||||||
callback: function () {
|
|
||||||
$this->panelsUpdate();
|
|
||||||
},
|
|
||||||
mandatoryParameters: ['ID'],
|
|
||||||
optionalParameters: ['name=<name>', 'A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>', 'self=<yes|no>']))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'delete',
|
|
||||||
callback: function () {
|
|
||||||
$this->panelsDelete();
|
|
||||||
},
|
|
||||||
mandatoryParameters: ['ID']))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'apiping',
|
|
||||||
callback: function () {
|
|
||||||
$this->apiPing(type: 'panel');
|
|
||||||
},
|
|
||||||
optionalParameters: ['ID'])))
|
|
||||||
->addCommandGroup(commandGroup: (new CommandGroup(name: 'nameservers', description: 'available nameservers'))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'list',
|
|
||||||
callback: function () {
|
|
||||||
$this->nameserversList();
|
|
||||||
}))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'create',
|
|
||||||
callback: function () {
|
|
||||||
$this->nameserversCreate();
|
|
||||||
},
|
|
||||||
mandatoryParameters: ['name'],
|
|
||||||
optionalParameters: ['A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>']))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'update',
|
|
||||||
callback: function () {
|
|
||||||
$this->nameserversUpdate();
|
|
||||||
},
|
|
||||||
mandatoryParameters: ['ID'],
|
|
||||||
optionalParameters: ['name=<name>', 'A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>']))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'delete',
|
|
||||||
callback: function () {
|
|
||||||
$this->nameserversDelete();
|
|
||||||
},
|
|
||||||
mandatoryParameters: ['ID']))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'apiping',
|
|
||||||
callback: function () {
|
|
||||||
$this->apiPing(type: 'nameserver');
|
|
||||||
},
|
|
||||||
optionalParameters: ['ID'])))
|
|
||||||
->addCommandGroup(commandGroup: (new CommandGroup(name: 'domains', description: 'configured domains'))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'list',
|
|
||||||
callback: function () {
|
|
||||||
$this->domainsList();
|
|
||||||
}))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'update',
|
|
||||||
callback: function () {
|
|
||||||
$this->domainsUpdate();
|
|
||||||
},
|
|
||||||
// mandatoryParameters: ['name'],
|
|
||||||
// optionalParameters: ['A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>'])))
|
|
||||||
description: 'Update zone files')))
|
|
||||||
->addCommandGroup(commandGroup: (new CommandGroup(name: 'dyndns', description: 'handle DynDNS entries'))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'list',
|
|
||||||
callback: function () {
|
|
||||||
$this->dynDnsList();
|
|
||||||
}))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'create',
|
|
||||||
callback: function () {
|
|
||||||
$this->dynDnsCreate();
|
|
||||||
},
|
|
||||||
mandatoryParameters: ['hostname.example.com', 'password'],
|
|
||||||
optionalParameters: ['A=<IPv4>', 'AAAA=<IPv6>'],
|
|
||||||
description: 'FQDN within a domain where this server is master'))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'update',
|
|
||||||
callback: function () {
|
|
||||||
$this->dynDnyUpdate();
|
|
||||||
},
|
|
||||||
mandatoryParameters: ['hostname.example.com',],
|
|
||||||
optionalParameters: ['password=<password>', 'A=<IPv4>', 'AAAA=<IPv6>']))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'delete',
|
|
||||||
callback: function () {
|
|
||||||
$this->dynDnsDelete();
|
|
||||||
},
|
|
||||||
mandatoryParameters: ['ID'])))
|
|
||||||
->addCommandGroup(commandGroup: (new CommandGroup(name: 'migrations', description: 'maintain database migrations'))
|
|
||||||
->addCommand(command: new Command(
|
->addCommand(command: new Command(
|
||||||
name: 'status',
|
name: 'status',
|
||||||
callback: function () {
|
callback: function () {
|
||||||
|
@ -290,16 +289,32 @@ class CLIController
|
||||||
$this->migrationsMigrate();
|
$this->migrationsMigrate();
|
||||||
},
|
},
|
||||||
description: 'Apply a new migration file'
|
description: 'Apply a new migration file'
|
||||||
))
|
));
|
||||||
->addCommand(command: new Command(
|
|
||||||
|
$env = $this->configController->getConfig(configKey: 'env');
|
||||||
|
$makeEnvs = ['dev', 'test'];
|
||||||
|
|
||||||
|
if (in_array(needle: $env, haystack: $makeEnvs)) {
|
||||||
|
$makeMigrationsCommand = new Command(
|
||||||
name: 'make',
|
name: 'make',
|
||||||
callback: function () {
|
callback: function () {
|
||||||
$this->migrationsMake();
|
$this->migrationsMake();
|
||||||
},
|
},
|
||||||
description: '!Use only on dev environments, not in production! Build a new migration file'
|
description: 'Build a new migration file'
|
||||||
))
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
$migrationsGroup->addCommand(command: $makeMigrationsCommand);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->commandGroupContainer = (new CommandGroupContainer())
|
||||||
|
->addCommandGroup(commandGroup: $apikeyGroup)
|
||||||
|
->addCommandGroup($cronGroup)
|
||||||
|
->addCommandGroup($panelsGroup)
|
||||||
|
->addCommandGroup($domainsGroup)
|
||||||
|
->addCommandGroup($nameserversGroup)
|
||||||
|
->addCommandGroup($dyndnsGroup)
|
||||||
|
->addCommandGroup($checkGroup)
|
||||||
|
->addCommandGroup($migrationsGroup);
|
||||||
|
|
||||||
|
|
||||||
// ->addCommandGroup(commandGroup: (new CommandGroup(name: 'webmail', description: 'manage webmail setup'))
|
// ->addCommandGroup(commandGroup: (new CommandGroup(name: 'webmail', description: 'manage webmail setup'))
|
||||||
// ->addCommand(command: new Command(
|
// ->addCommand(command: new Command(
|
||||||
|
|
Loading…
Reference in New Issue