move default buildNum and version into config
This commit is contained in:
parent
d05d6a7f32
commit
09875a0fa1
|
@ -114,18 +114,6 @@ describe('pluigns/elasticsearch', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('should update the build number to max integer if buildNum is template string', function () {
|
||||
get.withArgs('pkg.buildNum').returns('@@buildNum');
|
||||
client.create.returns(Promise.resolve());
|
||||
var response = { hits: { hits: [ { _id: '4.0.0', _source: { buildNum: 1 } } ] } };
|
||||
return upgrade(response).then(function (resp) {
|
||||
sinon.assert.calledOnce(client.create);
|
||||
var params = client.create.args[0][0];
|
||||
expect(params).to.have.property('body');
|
||||
expect(params.body).to.have.property('buildNum', Math.pow(2, 53) - 1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should log a message for upgrades', function () {
|
||||
get.withArgs('pkg.buildNum').returns(5801);
|
||||
client.create.returns(Promise.resolve());
|
||||
|
|
|
@ -8,7 +8,7 @@ module.exports = function (server) {
|
|||
type: 'config',
|
||||
body: {
|
||||
size: 1000,
|
||||
sort: [ { buildNum: { order: 'desc' } } ]
|
||||
sort: [ { buildNum: { order: 'desc', ignore_unmapped: true } } ]
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -19,10 +19,8 @@ module.exports = function (server) {
|
|||
return client.create({
|
||||
index: config.get('kibana.index'),
|
||||
type: 'config',
|
||||
body: {
|
||||
buildNum: config.get('env.prod') ? config.get('pkg.buildNum') : MAX_INTEGER
|
||||
},
|
||||
id: config.get('env.prod') ? config.get('pkg.version') : '@@version'
|
||||
body: { buildNum: config.get('pkg.buildNum') },
|
||||
id: config.get('pkg.version')
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -40,10 +38,7 @@ module.exports = function (server) {
|
|||
|
||||
// if the build number is still the template string (which it wil be in development)
|
||||
// then we need to set it to the max interger. Otherwise we will set it to the build num
|
||||
body._source.buildNum = MAX_INTEGER;
|
||||
if (!/^@@/.test(config.get('pkg.buildNum'))) {
|
||||
body._source.buildNum = parseInt(config.get('pkg.buildNum'), 10);
|
||||
}
|
||||
body._source.buildNum = config.get('pkg.buildNum');
|
||||
|
||||
server.log(['plugin', 'elasticsearch'], {
|
||||
tmpl: 'Upgrade config from <%= prevVersion %> to <%= newVersion %>',
|
||||
|
|
|
@ -8,13 +8,13 @@ let path = require('path');
|
|||
let utils = require('requirefrom')('src/utils');
|
||||
let fromRoot = utils('fromRoot');
|
||||
let pkg = utils('packageJson');
|
||||
let buildNum = get(pkg, 'build.num', '@@buildNum');
|
||||
let buildNum = get(pkg, 'build.num', Math.pow(2, 53) - 1);
|
||||
|
||||
module.exports = Joi.object({
|
||||
|
||||
pkg: Joi.object({
|
||||
version: Joi.string().valid(pkg.version).default(pkg.version),
|
||||
buildNum: Joi.string().valid(buildNum).default(buildNum)
|
||||
buildNum: Joi.number().valid(buildNum).default(buildNum)
|
||||
}).default(),
|
||||
|
||||
env: Joi.object({
|
||||
|
|
|
@ -2,6 +2,6 @@ module.exports = function (grunt) {
|
|||
var exec = require('child_process').execSync;
|
||||
grunt.registerTask('get_build_props', function () {
|
||||
grunt.config.set('commitSha', String(exec('git rev-parse HEAD')).trim());
|
||||
grunt.config.set('buildNum', String(exec('git log --format="%h" | wc -l')).trim());
|
||||
grunt.config.set('buildNum', parseFloat(exec('git log --format="%h" | wc -l')).trim());
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue