From 95177455a00ee6b4a0231ae1d380e61aa571d399 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Fri, 2 Sep 2016 14:28:28 -0700 Subject: [PATCH] Remove old config population function --- src/core_plugins/timelion/init.js | 2 -- .../timelion/server/lib/populate_config.js | 35 ------------------- 2 files changed, 37 deletions(-) delete mode 100644 src/core_plugins/timelion/server/lib/populate_config.js diff --git a/src/core_plugins/timelion/init.js b/src/core_plugins/timelion/init.js index 9e6a0f1223d13..36fb506d8de62 100644 --- a/src/core_plugins/timelion/init.js +++ b/src/core_plugins/timelion/init.js @@ -4,8 +4,6 @@ var processFunctionDefinition = require('./server/lib/process_function_definitio module.exports = function (server) { //var config = server.config(); - require('./server/lib/populate_config')(server); - require('./server/routes/run.js')(server); require('./server/routes/functions.js')(server); require('./server/routes/validate_es.js')(server); diff --git a/src/core_plugins/timelion/server/lib/populate_config.js b/src/core_plugins/timelion/server/lib/populate_config.js deleted file mode 100644 index c2e323fb9db50..0000000000000 --- a/src/core_plugins/timelion/server/lib/populate_config.js +++ /dev/null @@ -1,35 +0,0 @@ -var _ = require('lodash'); -var getNamespacedSettings = require('./get_namespaced_settings'); - -module.exports = function (server) { - - // Namespace everything in timelion.json - var timelionDefaults = getNamespacedSettings(); - - // Get all existing "advanced settings" - server.uiSettings().getAll().then((existingSettings) => { - - // Find all timelion settings that don't yet exist in kibana's config - var missingKeys = _.reduce(timelionDefaults, (result, value, key) => { - if (existingSettings[key] == null) result.push(key); - return result; - }, []); - - // Recursive function writes one of the missing keys at a time - // If we just spray and pray HTTP requests we will get version conflicts. - function writeMissing(keys) { - - // Pop one key off the missingKeys array unless it is empty - if (!keys.length) return; - var key = keys.pop(); - var timelionDefault = timelionDefaults[key]; - - server.uiSettings() - .set(key, timelionDefault) - .then(() => writeMissing(keys)); - } - - writeMissing(missingKeys); - }); - -};