mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-03-13 09:20:00 +00:00
add basic server config validation
This commit is contained in:
parent
e89211ab72
commit
73c7883904
8
app.js
8
app.js
@ -12,7 +12,8 @@ var env = process.env.NODE_ENV || 'development',
|
||||
notifier = require('./lib/notifier'),
|
||||
project = require('./lib/project'),
|
||||
libLogger = require('./lib/logger'),
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
EventEmitter = require('events').EventEmitter,
|
||||
validateConfig = require('./lib/validateConfig');
|
||||
|
||||
var app = new EventEmitter(),
|
||||
logger = libLogger('app'),
|
||||
@ -181,6 +182,11 @@ Steppy(
|
||||
|
||||
reader.load(app.config.paths.data, 'config', this.slot());
|
||||
},
|
||||
function(err, mkdirResult, config) {
|
||||
this.pass(mkdirResult);
|
||||
|
||||
validateConfig(config, this.slot());
|
||||
},
|
||||
function(err, mkdirResult, config) {
|
||||
_(app.config).defaults(config);
|
||||
_(app.config).defaults(configDefaults);
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
plugins:
|
||||
# - nci-mail-notification
|
||||
# - nci-jabber-notification
|
||||
# plugins:
|
||||
# - nci-mail-notification
|
||||
# - nci-jabber-notification
|
||||
|
||||
nodes:
|
||||
- type: local
|
||||
@ -14,7 +14,6 @@ http:
|
||||
|
||||
storage:
|
||||
backend: memdown
|
||||
# backend: leveldown
|
||||
|
||||
notify:
|
||||
mail:
|
||||
|
53
lib/validateConfig.js
Normal file
53
lib/validateConfig.js
Normal file
@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
var Steppy = require('twostep').Steppy,
|
||||
validateParams = require('./validateParams');
|
||||
|
||||
module.exports = function(config, callback) {
|
||||
Steppy(
|
||||
function() {
|
||||
validateParams(config, {
|
||||
type: 'object',
|
||||
properties: {
|
||||
plugins: {
|
||||
type: 'array',
|
||||
items: {type: 'string'}
|
||||
},
|
||||
nodes: {
|
||||
type: 'array',
|
||||
required: true,
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
type: {type: 'string', enum: ['local']},
|
||||
maxExecutorsCount: {type: 'integer'}
|
||||
}
|
||||
},
|
||||
minItems: 1
|
||||
},
|
||||
storage: {
|
||||
type: 'object',
|
||||
required: true,
|
||||
properties: {
|
||||
backend: {type: 'string', required: true}
|
||||
}
|
||||
},
|
||||
notify: {
|
||||
type: 'object'
|
||||
}
|
||||
},
|
||||
additionalProperties: true
|
||||
});
|
||||
|
||||
this.pass(null);
|
||||
},
|
||||
function(err) {
|
||||
if (err) {
|
||||
err.message = (
|
||||
'Error during validation server config: "' + err.message
|
||||
);
|
||||
}
|
||||
callback(err, config);
|
||||
}
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue
Block a user