[generate/aliases] merge the aliases into a single file

This commit is contained in:
Spencer Alger
2014-10-27 23:14:36 -07:00
parent 625caccd8d
commit af69d18108
4 changed files with 185 additions and 165 deletions

View File

@ -69,6 +69,7 @@
"nock": "~0.28.3", "nock": "~0.28.3",
"open": "0.0.4", "open": "0.0.4",
"optimist": "~0.6.0", "optimist": "~0.6.0",
"semver": "~4.1.0",
"sinon": "~1.7.3", "sinon": "~1.7.3",
"xmlbuilder": "~0.4.3" "xmlbuilder": "~0.4.3"
}, },

View File

@ -1,98 +1,166 @@
module.exports = { module.exports = [
'nodes.hotThreads': [ {
'/_cluster/nodes/hotthreads', version: '0.90.x',
'/_cluster/nodes/hot_threads', aliases: {
'/_nodes/hot_threads', 'cluster.nodeHotThreads': [
'/_cluster/nodes/{node_id}/hotthreads', '/_cluster/nodes/hotthreads',
'/_cluster/nodes/{node_id}/hot_threads', '/_cluster/nodes/hot_threads',
'/_nodes/{node_id}/hot_threads' '/_nodes/hot_threads',
], '/_cluster/nodes/{node_id}/hotthreads',
'nodes.info': [ '/_cluster/nodes/{node_id}/hot_threads',
'/_cluster/nodes', '/_nodes/{node_id}/hot_threads'
'/_nodes/settings', ],
'/_nodes/os', 'cluster.nodeInfo': [
'/_nodes/process', '/_cluster/nodes',
'/_nodes/jvm', '/_nodes/settings',
'/_nodes/thread_pool', '/_nodes/os',
'/_nodes/network', '/_nodes/process',
'/_nodes/transport', '/_nodes/jvm',
'/_nodes/http', '/_nodes/thread_pool',
'/_nodes/plugin', '/_nodes/network',
'/_cluster/nodes/{node_id}', '/_nodes/transport',
'/_nodes/{node_id}/settings', '/_nodes/http',
'/_nodes/{node_id}/os', '/_nodes/plugin',
'/_nodes/{node_id}/process', '/_cluster/nodes/{node_id}',
'/_nodes/{node_id}/jvm', '/_nodes/{node_id}/settings',
'/_nodes/{node_id}/thread_pool', '/_nodes/{node_id}/os',
'/_nodes/{node_id}/network', '/_nodes/{node_id}/process',
'/_nodes/{node_id}/transport', '/_nodes/{node_id}/jvm',
'/_nodes/{node_id}/http', '/_nodes/{node_id}/thread_pool',
'/_nodes/{node_id}/plugin' '/_nodes/{node_id}/network',
], '/_nodes/{node_id}/transport',
'nodes.shutdown': [ '/_nodes/{node_id}/http',
'/_cluster/nodes/_shutdown' '/_nodes/{node_id}/plugin'
], ],
'nodes.stats': [ 'cluster.nodeShutdown': [
'/_cluster/nodes/stats', '/_cluster/nodes/_shutdown'
'/_nodes/stats/{metric_family}', ],
'/_nodes/stats/indices/{metric}/{fields}', 'cluster.nodeStats': [
'/_cluster/nodes/{node_id}/stats', '/_cluster/nodes/stats',
'/_nodes/{node_id}/stats/{metric_family}', '/_nodes/stats/{metric_family}',
'/_nodes/{node_id}/stats/indices/{metric}/{fields}' '/_nodes/stats/indices/{metric}/{fields}',
], '/_cluster/nodes/{node_id}/stats',
'get': [ '/_nodes/{node_id}/stats/{metric_family}',
'/{index}/{type}/{id}/_source' '/_nodes/{node_id}/stats/indices/{metric}/{fields}'
], ],
'indices.deleteMapping': [ 'get': [
'/{index}/{type}', '/{index}/{type}/{id}/_source'
'/{index}/_mapping/{type}', ],
'/{index}/{type}/_mappings', 'indices.deleteMapping': [
'/{index}/_mappings/{type}' '/{index}/{type}/_mapping'
], ],
'indices.putWarmer': [ 'indices.stats': [
// '/_warmer/{name}', '_stats/{metric_family}',
// '/{index}/_warmer/{name}', '/_stats/indexing',
// '/{index}/{type}/_warmer/{name}', '/_stats/indexing/{indexing_types}',
'/_warmers/{name}', '/_stats/search/{search_groups}',
'/{index}/_warmers/{name}', '/_stats/fielddata/{fields}',
'/{index}/{type}/_warmers/{name}' '/{index}/_stats/{metric_family}',
], '/{index}/_stats/indexing',
'indices.deleteWarmer': [ '/{index}/_stats/search/{search_groups}',
// '/{index}/_warmer/{name}', '/{index}/_stats/fielddata/{fields}'
'/{index}/_warmer', ]
'/{index}/_warmers', }
'/{index}/_warmers/{name}' },
], {
'indices.deleteAlias': [ version: '>=1.0.0',
// '/{index}/_alias/{name}', aliases: {
'/{index}/_aliases/{name}' 'nodes.hotThreads': [
], '/_cluster/nodes/hotthreads',
'indices.putAlias': [ '/_cluster/nodes/hot_threads',
// '/{index}/_alias/{name}', '/_nodes/hot_threads',
// '/_alias/{name}', '/_cluster/nodes/{node_id}/hotthreads',
'/{index}/_aliases/{name}', '/_cluster/nodes/{node_id}/hot_threads',
'/_aliases/{name}' '/_nodes/{node_id}/hot_threads'
], ],
'indices.putMapping': [ 'nodes.info': [
// '/{index}/_mapping/{type}', '/_cluster/nodes',
// '/_mapping/{type}', '/_nodes/settings',
'/{index}/{type}/_mapping', '/_nodes/os',
'/{index}/{type}/_mappings', '/_nodes/process',
'/{index}/_mappings/{type}', '/_nodes/jvm',
'/_mappings/{type}' '/_nodes/thread_pool',
], '/_nodes/network',
'indices.stats': [ '/_nodes/transport',
'_stats/{metric_family}', '/_nodes/http',
'/_stats/indexing', '/_nodes/plugin',
'/_stats/indexing/{indexing_types}', '/_cluster/nodes/{node_id}',
'/_stats/search/{search_groups}', '/_nodes/{node_id}/settings',
'/_stats/fielddata/{fields}', '/_nodes/{node_id}/os',
'/{index}/_stats/{metric_family}', '/_nodes/{node_id}/process',
'/{index}/_stats/indexing', '/_nodes/{node_id}/jvm',
'/{index}/_stats/search/{search_groups}', '/_nodes/{node_id}/thread_pool',
'/{index}/_stats/fielddata/{fields}' '/_nodes/{node_id}/network',
], '/_nodes/{node_id}/transport',
'snapshot.create': [ '/_nodes/{node_id}/http',
'/_snapshot/{repository}/{snapshot}/_create' '/_nodes/{node_id}/plugin'
] ],
}; 'nodes.shutdown': [
'/_cluster/nodes/_shutdown'
],
'nodes.stats': [
'/_cluster/nodes/stats',
'/_nodes/stats/{metric_family}',
'/_nodes/stats/indices/{metric}/{fields}',
'/_cluster/nodes/{node_id}/stats',
'/_nodes/{node_id}/stats/{metric_family}',
'/_nodes/{node_id}/stats/indices/{metric}/{fields}'
],
'get': [
'/{index}/{type}/{id}/_source'
],
'indices.deleteMapping': [
'/{index}/{type}',
'/{index}/_mapping/{type}',
'/{index}/{type}/_mappings',
'/{index}/_mappings/{type}'
],
'indices.putWarmer': [
// '/_warmer/{name}',
// '/{index}/_warmer/{name}',
// '/{index}/{type}/_warmer/{name}',
'/_warmers/{name}',
'/{index}/_warmers/{name}',
'/{index}/{type}/_warmers/{name}'
],
'indices.deleteWarmer': [
// '/{index}/_warmer/{name}',
'/{index}/_warmer',
'/{index}/_warmers',
'/{index}/_warmers/{name}'
],
'indices.deleteAlias': [
// '/{index}/_alias/{name}',
'/{index}/_aliases/{name}'
],
'indices.putAlias': [
// '/{index}/_alias/{name}',
// '/_alias/{name}',
'/{index}/_aliases/{name}',
'/_aliases/{name}'
],
'indices.putMapping': [
// '/{index}/_mapping/{type}',
// '/_mapping/{type}',
'/{index}/{type}/_mapping',
'/{index}/{type}/_mappings',
'/{index}/_mappings/{type}',
'/_mappings/{type}'
],
'indices.stats': [
'_stats/{metric_family}',
'/_stats/indexing',
'/_stats/indexing/{indexing_types}',
'/_stats/search/{search_groups}',
'/_stats/fielddata/{fields}',
'/{index}/_stats/{metric_family}',
'/{index}/_stats/indexing',
'/{index}/_stats/search/{search_groups}',
'/{index}/_stats/fielddata/{fields}'
],
'snapshot.create': [
'/_snapshot/{repository}/{snapshot}/_create'
]
}
}
];

View File

@ -1,60 +0,0 @@
module.exports = {
'cluster.nodeHotThreads': [
'/_cluster/nodes/hotthreads',
'/_cluster/nodes/hot_threads',
'/_nodes/hot_threads',
'/_cluster/nodes/{node_id}/hotthreads',
'/_cluster/nodes/{node_id}/hot_threads',
'/_nodes/{node_id}/hot_threads'
],
'cluster.nodeInfo': [
'/_cluster/nodes',
'/_nodes/settings',
'/_nodes/os',
'/_nodes/process',
'/_nodes/jvm',
'/_nodes/thread_pool',
'/_nodes/network',
'/_nodes/transport',
'/_nodes/http',
'/_nodes/plugin',
'/_cluster/nodes/{node_id}',
'/_nodes/{node_id}/settings',
'/_nodes/{node_id}/os',
'/_nodes/{node_id}/process',
'/_nodes/{node_id}/jvm',
'/_nodes/{node_id}/thread_pool',
'/_nodes/{node_id}/network',
'/_nodes/{node_id}/transport',
'/_nodes/{node_id}/http',
'/_nodes/{node_id}/plugin'
],
'cluster.nodeShutdown': [
'/_cluster/nodes/_shutdown'
],
'cluster.nodeStats': [
'/_cluster/nodes/stats',
'/_nodes/stats/{metric_family}',
'/_nodes/stats/indices/{metric}/{fields}',
'/_cluster/nodes/{node_id}/stats',
'/_nodes/{node_id}/stats/{metric_family}',
'/_nodes/{node_id}/stats/indices/{metric}/{fields}'
],
'get': [
'/{index}/{type}/{id}/_source'
],
'indices.deleteMapping': [
'/{index}/{type}/_mapping'
],
'indices.stats': [
'_stats/{metric_family}',
'/_stats/indexing',
'/_stats/indexing/{indexing_types}',
'/_stats/search/{search_groups}',
'/_stats/fielddata/{fields}',
'/{index}/_stats/{metric_family}',
'/{index}/_stats/indexing',
'/{index}/_stats/search/{search_groups}',
'/{index}/_stats/fielddata/{fields}'
]
};

View File

@ -9,6 +9,7 @@ module.exports = function (branch, done) {
var async = require('async'); var async = require('async');
var chalk = require('chalk'); var chalk = require('chalk');
var path = require('path'); var path = require('path');
var semver = require('semver');
var fromRoot = path.join.bind(path, require('find-root')(__dirname)); var fromRoot = path.join.bind(path, require('find-root')(__dirname));
var templates = require('./templates'); var templates = require('./templates');
var urlParamRE = /\{(\w+)\}/g; var urlParamRE = /\{(\w+)\}/g;
@ -18,14 +19,24 @@ module.exports = function (branch, done) {
var docVars; // slightly modified clone of apiSpec for the docs var docVars; // slightly modified clone of apiSpec for the docs
var branchSuffix = utils.branchSuffix(branch); var branchSuffix = utils.branchSuffix(branch);
var branchAsVersion = (function () {
var m;
// master === the highest version number
if (branch === 'master') return '999.999.999';
// n.m -> n.m.0
if (m = branch.match(/^\d+\.\d+$/)) return branch + '.0';
// n.x -> n.0.0
if (m = branch.match(/^(\d+)\.x$/i)) return m[1] + '.0.0';
throw new Error('unable to convert branch "' + branch + '" to semver');
}());
var esDir = fromRoot('src/_elasticsearch_' + _.snakeCase(branch)); var esDir = fromRoot('src/_elasticsearch_' + _.snakeCase(branch));
var aliases; var aliases = _.transform(require('./aliases'), function (aliases, rule) {
try { if (semver.satisfies(branchAsVersion, rule.version)) {
aliases = require('./aliases_' + _.snakeCase(branch)); _.assign(aliases, rule.aliases);
} catch (e) { }
// fall back to the master aliases }, {});
aliases = require('./aliases');
}
var steps = [ var steps = [
readSpecFiles, readSpecFiles,