mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 23:24:52 +09:00
Add ctl master plugin list command
Add command to list the plugins enabled on the master server and their versions to clusterioctl.
This commit is contained in:
1 parent
6c9d3d8893
commit
7797ee708a
4 files changed
+35
-2
No files matched your search
@@ -56,6 +56,7 @@ Version 2.0.0
|
||||
- Added option to configure timeout for exported Prometheus metrics.
|
||||
- Added option to set address to bind HTTP(S) port to.
|
||||
- Added an overview of the installed plugins to the web interface.
|
||||
- Added clusterioctl command to list plugins on the master server.
|
||||
|
||||
### Changes
|
||||
|
||||
|
||||
+27
-2
@@ -13,6 +13,7 @@ const events = require("events");
|
||||
const path = require("path");
|
||||
const winston = require("winston");
|
||||
const setBlocking = require("set-blocking");
|
||||
const phin = require("phin");
|
||||
|
||||
const libLink = require("@clusterio/lib/link");
|
||||
const libErrors = require("@clusterio/lib/errors");
|
||||
@@ -104,6 +105,25 @@ masterConfigCommands.add(new libCommand.Command({
|
||||
masterCommands.add(masterConfigCommands);
|
||||
|
||||
|
||||
const masterPluginCommands = new libCommand.CommandTree({
|
||||
name: "plugin", alias: ["p"], description: "master plugin inspection",
|
||||
});
|
||||
masterPluginCommands.add(new libCommand.Command({
|
||||
definition: ["list", "List plugins on master"],
|
||||
handler: async function(args, control) {
|
||||
let url = new URL(control.config.get("control.master_url"));
|
||||
url.pathname += "api/plugins";
|
||||
let response = await phin({
|
||||
url,
|
||||
parse: "json",
|
||||
core: { ca: control.tlsCa },
|
||||
});
|
||||
print(asTable(response.body));
|
||||
},
|
||||
}));
|
||||
masterCommands.add(masterPluginCommands);
|
||||
|
||||
|
||||
const slaveCommands = new libCommand.CommandTree({ name: "slave", description: "Slave management" });
|
||||
slaveCommands.add(new libCommand.Command({
|
||||
definition: [["list", "l"], "List slaves connected to the master"],
|
||||
@@ -698,10 +718,15 @@ class ControlConnector extends libLink.WebSocketClientConnector {
|
||||
*/
|
||||
class Control extends libLink.Link {
|
||||
|
||||
constructor(connector, tlsCa, controlPlugins) {
|
||||
constructor(connector, controlConfig, tlsCa, controlPlugins) {
|
||||
super("control", "master", connector);
|
||||
libLink.attachAllMessages(this);
|
||||
|
||||
/**
|
||||
* Control config used for connecting to the master.
|
||||
* @type {module:lib/config.ControlConfig}
|
||||
*/
|
||||
this.config = controlConfig;
|
||||
/**
|
||||
* Certificate authority used to validate TLS connections to the master.
|
||||
* @type {?string}
|
||||
@@ -922,7 +947,7 @@ async function startControl() {
|
||||
tlsCa,
|
||||
controlConfig.get("control.master_token")
|
||||
);
|
||||
let control = new Control(controlConnector, tlsCa, controlPlugins);
|
||||
let control = new Control(controlConnector, controlConfig, tlsCa, controlPlugins);
|
||||
try {
|
||||
await controlConnector.connect();
|
||||
} catch (err) {
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"as-table": "^1.0.31",
|
||||
"chalk": "^3.0.0",
|
||||
"fs-extra": "^8.1.0",
|
||||
"phin": "^3.5.1",
|
||||
"winston": "^3.3.3",
|
||||
"yargs": "^14.2.0"
|
||||
},
|
||||
|
||||
@@ -71,6 +71,12 @@ describe("Integration of Clusterio", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("master plugin list", function() {
|
||||
it("runs", async function() {
|
||||
await execCtl("master plugin list");
|
||||
});
|
||||
});
|
||||
|
||||
describe("slave list", function() {
|
||||
it("runs", async function() {
|
||||
await execCtl("slave list");
|
||||
|
||||
Reference in new issue
Block a user