[add] conf-schema exposition
This commit is contained in:
parent
196ee61fd9
commit
c23175163b
|
@ -652,8 +652,8 @@ namespace _munin.conf
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
function schema(
|
export function schema(
|
||||||
version : string
|
version : string = "3"
|
||||||
) : lib_plankton.conf.type_schema
|
) : lib_plankton.conf.type_schema
|
||||||
{
|
{
|
||||||
switch (version) {
|
switch (version) {
|
||||||
|
@ -679,7 +679,6 @@ namespace _munin.conf
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
case "2":
|
case "2":
|
||||||
case "3": {
|
case "3": {
|
||||||
return {
|
return {
|
||||||
|
|
127
source/main.ts
127
source/main.ts
|
@ -176,6 +176,15 @@ namespace _munin
|
||||||
"info": "path to configuration file",
|
"info": "path to configuration file",
|
||||||
"name": "conf-path",
|
"name": "conf-path",
|
||||||
}),
|
}),
|
||||||
|
"conf_schema": lib_plankton.args.class_argument.volatile({
|
||||||
|
"indicators_long": ["conf-schema"],
|
||||||
|
"indicators_short": ["s"],
|
||||||
|
"type": lib_plankton.args.enum_type.string,
|
||||||
|
"mode": lib_plankton.args.enum_mode.replace,
|
||||||
|
"default": "",
|
||||||
|
"info": "only print the configuration schema in a specific version (latest version via argument '_')",
|
||||||
|
"name": "conf-schema",
|
||||||
|
}),
|
||||||
"conf_expose": lib_plankton.args.class_argument.volatile({
|
"conf_expose": lib_plankton.args.class_argument.volatile({
|
||||||
"indicators_long": ["conf-expose"],
|
"indicators_long": ["conf-expose"],
|
||||||
"indicators_short": ["e"],
|
"indicators_short": ["e"],
|
||||||
|
@ -187,11 +196,11 @@ namespace _munin
|
||||||
}),
|
}),
|
||||||
"single_run": lib_plankton.args.class_argument.volatile({
|
"single_run": lib_plankton.args.class_argument.volatile({
|
||||||
"indicators_long": ["single-run"],
|
"indicators_long": ["single-run"],
|
||||||
"indicators_short": ["s"],
|
"indicators_short": ["x"],
|
||||||
"type": lib_plankton.args.enum_type.boolean,
|
"type": lib_plankton.args.enum_type.boolean,
|
||||||
"mode": lib_plankton.args.enum_mode.replace,
|
"mode": lib_plankton.args.enum_mode.replace,
|
||||||
"default": false,
|
"default": false,
|
||||||
"info": "whether to only execute on iteration at run",
|
"info": "whether to only execute one iteration at run",
|
||||||
"name": "single-run",
|
"name": "single-run",
|
||||||
}),
|
}),
|
||||||
"verbosity": lib_plankton.args.class_argument.volatile({
|
"verbosity": lib_plankton.args.class_argument.volatile({
|
||||||
|
@ -240,46 +249,10 @@ namespace _munin
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// init
|
if (args.conf_schema !== "") {
|
||||||
const conf : _munin.conf.type_conf = await _munin.conf.load(args.conf_path);
|
|
||||||
lib_plankton.log.set_main_logger(
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"kind": "filtered",
|
|
||||||
"data": {
|
|
||||||
"core": {
|
|
||||||
"kind": "std",
|
|
||||||
"data": {
|
|
||||||
"target": "stdout",
|
|
||||||
"format": {
|
|
||||||
"kind": "human_readable",
|
|
||||||
"data": {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"predicate": [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"item": {
|
|
||||||
"kind": "level",
|
|
||||||
"data": {
|
|
||||||
"threshold": args.verbosity,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
// exec
|
|
||||||
if (args.conf_expose) {
|
|
||||||
process.stdout.write(
|
process.stdout.write(
|
||||||
lib_plankton.json.encode(
|
lib_plankton.json.encode(
|
||||||
conf,
|
_munin.conf.schema((args.conf_schema === "_") ? undefined : args.conf_schema),
|
||||||
{
|
{
|
||||||
"formatted": true,
|
"formatted": true,
|
||||||
}
|
}
|
||||||
|
@ -288,20 +261,70 @@ namespace _munin
|
||||||
"\n"
|
"\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
switch (/*args.action*/"run") {
|
else {
|
||||||
default: {
|
// init
|
||||||
throw (new Error("unhandled action: " + args.action));
|
const conf : _munin.conf.type_conf = await _munin.conf.load(args.conf_path);
|
||||||
break;
|
lib_plankton.log.set_main_logger(
|
||||||
}
|
[
|
||||||
case "run": {
|
|
||||||
run(
|
|
||||||
conf,
|
|
||||||
{
|
{
|
||||||
"single_run": args.single_run,
|
"kind": "filtered",
|
||||||
"dry_run": args.dry_run,
|
"data": {
|
||||||
}
|
"core": {
|
||||||
|
"kind": "std",
|
||||||
|
"data": {
|
||||||
|
"target": "stdout",
|
||||||
|
"format": {
|
||||||
|
"kind": "human_readable",
|
||||||
|
"data": {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"predicate": [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"item": {
|
||||||
|
"kind": "level",
|
||||||
|
"data": {
|
||||||
|
"threshold": args.verbosity,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
// exec
|
||||||
|
if (args.conf_expose) {
|
||||||
|
process.stdout.write(
|
||||||
|
lib_plankton.json.encode(
|
||||||
|
conf,
|
||||||
|
{
|
||||||
|
"formatted": true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
+
|
||||||
|
"\n"
|
||||||
);
|
);
|
||||||
break;
|
}
|
||||||
|
switch (/*args.action*/"run") {
|
||||||
|
default: {
|
||||||
|
throw (new Error("unhandled action: " + args.action));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "run": {
|
||||||
|
run(
|
||||||
|
conf,
|
||||||
|
{
|
||||||
|
"single_run": args.single_run,
|
||||||
|
"dry_run": args.dry_run,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue