Skip to content

Commit

Permalink
[7.x] rename bluebird imports to stop impersonating global.Pro… (#47544)
Browse files Browse the repository at this point in the history
* rename bluebird imports to stop impersonating global.Promise

* forgot to save a couple files

* found a missing instance

* one more
  • Loading branch information
Spencer authored Oct 8, 2019
1 parent e27dce9 commit 95f482d
Show file tree
Hide file tree
Showing 23 changed files with 93 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import _ from 'lodash';
import Promise from 'bluebird';
import Bluebird from 'bluebird';
import sinon from 'sinon';
import expect from '@kbn/expect';

Expand Down Expand Up @@ -74,13 +74,13 @@ describe('plugins/elasticsearch', () => {
}

const cluster = server.plugins.elasticsearch.getCluster('admin');
cluster.callWithInternalUser.withArgs('nodes.info', sinon.match.any).returns(Promise.resolve({ nodes: nodes }));
cluster.callWithInternalUser.withArgs('nodes.info', sinon.match.any).returns(Bluebird.resolve({ nodes: nodes }));
}

function setNodeWithoutHTTP(version) {
const nodes = { 'node-without-http': { version, ip: 'ip' } };
const cluster = server.plugins.elasticsearch.getCluster('admin');
cluster.callWithInternalUser.withArgs('nodes.info', sinon.match.any).returns(Promise.resolve({ nodes: nodes }));
cluster.callWithInternalUser.withArgs('nodes.info', sinon.match.any).returns(Bluebird.resolve({ nodes: nodes }));
}

it('returns true with single a node that matches', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import Promise from 'bluebird';
import Bluebird from 'bluebird';
import sinon from 'sinon';
import expect from '@kbn/expect';

Expand Down Expand Up @@ -58,11 +58,11 @@ describe('plugins/elasticsearch', () => {
};

cluster = { callWithInternalUser: sinon.stub(), errors: { NoConnections } };
cluster.callWithInternalUser.withArgs('index', sinon.match.any).returns(Promise.resolve());
cluster.callWithInternalUser.withArgs('mget', sinon.match.any).returns(Promise.resolve({ ok: true }));
cluster.callWithInternalUser.withArgs('get', sinon.match.any).returns(Promise.resolve({ found: false }));
cluster.callWithInternalUser.withArgs('search', sinon.match.any).returns(Promise.resolve({ hits: { hits: [] } }));
cluster.callWithInternalUser.withArgs('nodes.info', sinon.match.any).returns(Promise.resolve({
cluster.callWithInternalUser.withArgs('index', sinon.match.any).returns(Bluebird.resolve());
cluster.callWithInternalUser.withArgs('mget', sinon.match.any).returns(Bluebird.resolve({ ok: true }));
cluster.callWithInternalUser.withArgs('get', sinon.match.any).returns(Bluebird.resolve({ found: false }));
cluster.callWithInternalUser.withArgs('search', sinon.match.any).returns(Bluebird.resolve({ hits: { hits: [] } }));
cluster.callWithInternalUser.withArgs('nodes.info', sinon.match.any).returns(Bluebird.resolve({
nodes: {
'node-01': {
version: COMPATIBLE_VERSION_NUMBER,
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('plugins/elasticsearch', () => {
});

it('should set the cluster green if everything is ready', function () {
cluster.callWithInternalUser.withArgs('ping').returns(Promise.resolve());
cluster.callWithInternalUser.withArgs('ping').returns(Bluebird.resolve());

return health.run()
.then(function () {
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/elasticsearch/lib/health_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
* under the License.
*/

import Promise from 'bluebird';
import Bluebird from 'bluebird';
import kibanaVersion from './kibana_version';
import { ensureEsVersion } from './ensure_es_version';

export default function (plugin, server, requestDelay) {
plugin.status.yellow('Waiting for Elasticsearch');

function waitUntilReady() {
return new Promise((resolve) => {
return new Bluebird((resolve) => {
plugin.status.once('green', resolve);
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/legacy/core_plugins/kibana/server/lib/manage_uuid.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import uuid from 'uuid';
import Promise from 'bluebird';
import Bluebird from 'bluebird';
import { join as pathJoin } from 'path';
import { readFile as readFileCallback, writeFile as writeFileCallback } from 'fs';

Expand All @@ -30,7 +30,7 @@ export default async function manageUuid(server) {
const uuidFile = pathJoin(config.get('path.data'), fileName);

async function detectUuid() {
const readFile = Promise.promisify(readFileCallback);
const readFile = Bluebird.promisify(readFileCallback);
try {
const result = await readFile(uuidFile);
return result.toString(FILE_ENCODING);
Expand All @@ -46,7 +46,7 @@ export default async function manageUuid(server) {
}

async function writeUuid(uuid) {
const writeFile = Promise.promisify(writeFileCallback);
const writeFile = Bluebird.promisify(writeFileCallback);
try {
return await writeFile(uuidFile, uuid, { encoding: FILE_ENCODING });
} catch (err) {
Expand Down
12 changes: 6 additions & 6 deletions src/legacy/core_plugins/timelion/server/handlers/chain_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


import _ from 'lodash';
import Promise from 'bluebird';
import Bluebird from 'bluebird';
import { i18n } from '@kbn/i18n';

import parseSheet from './lib/parse_sheet.js';
Expand All @@ -46,7 +46,7 @@ export default function chainRunner(tlConfig) {

function resolveArgument(item) {
if (Array.isArray(item)) {
return Promise.all(_.map(item, resolveArgument));
return Bluebird.all(_.map(item, resolveArgument));
}

if (_.isObject(item)) {
Expand All @@ -55,7 +55,7 @@ export default function chainRunner(tlConfig) {
const itemFunctionDef = tlConfig.server.plugins.timelion.getFunction(item.function);
if (itemFunctionDef.cacheKey && queryCache[itemFunctionDef.cacheKey(item)]) {
stats.queryCount++;
return Promise.resolve(_.cloneDeep(queryCache[itemFunctionDef.cacheKey(item)]));
return Bluebird.resolve(_.cloneDeep(queryCache[itemFunctionDef.cacheKey(item)]));
}
return invoke(item.function, item.arguments);
}
Expand Down Expand Up @@ -98,7 +98,7 @@ export default function chainRunner(tlConfig) {

args = _.map(args, resolveArgument);

return Promise.all(args).then(function (args) {
return Bluebird.all(args).then(function (args) {
args.byName = indexArguments(functionDef, args);
return functionDef.fn(args, tlConfig);
});
Expand Down Expand Up @@ -133,7 +133,7 @@ export default function chainRunner(tlConfig) {
return args;
});
});
return Promise.all(seriesList).then(function (args) {
return Bluebird.all(seriesList).then(function (args) {
const list = _.chain(args).pluck('list').flatten().value();
const seriesList = _.merge.apply(this, _.flatten([{}, args]));
seriesList.list = list;
Expand Down Expand Up @@ -161,7 +161,7 @@ export default function chainRunner(tlConfig) {
return invoke(query.function, query.arguments);
}).value();

return Promise.settle(promises).then(function (resolvedDatasources) {
return Bluebird.settle(promises).then(function (resolvedDatasources) {

stats.queryTime = (new Date()).getTime();

Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/timelion/server/lib/alter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import Promise from 'bluebird';
import Bluebird from 'bluebird';
import _ from 'lodash';

/* @param {Array} args
Expand All @@ -29,7 +29,7 @@ import _ from 'lodash';

export default function alter(args, fn) {
// In theory none of the args should ever be promises. This is probably a waste.
return Promise.all(args).then(function (args) {
return Bluebird.all(args).then(function (args) {

const seriesList = args.shift();

Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/timelion/server/routes/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import Promise from 'bluebird';
import Bluebird from 'bluebird';
import _ from 'lodash';
import chainRunnerFn from '../handlers/chain_runner.js';
const timelionDefaults = require('../lib/get_namespaced_settings')();
Expand All @@ -44,7 +44,7 @@ export function runRoute(server) {
});

const chainRunner = chainRunnerFn(tlConfig);
const sheet = await Promise.all(chainRunner.processRequest(request.payload || {
const sheet = await Bluebird.all(chainRunner.processRequest(request.payload || {
sheet: [request.query.expression],
time: {
from: request.query.from,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import buildRequest from '../es/lib/build_request';
import createDateAgg from '../es/lib/create_date_agg';
import esResponse from './fixtures/es_response';

import Promise from 'bluebird';
import Bluebird from 'bluebird';
import _ from 'lodash';
import { expect } from 'chai';
import sinon from 'sinon';
Expand All @@ -39,7 +39,7 @@ function stubRequestAndServer(response, indexPatternSavedObjects = []) {
elasticsearch: {
getCluster: sinon.stub().withArgs('data').returns({
callWithRequest: function () {
return Promise.resolve(response);
return Bluebird.resolve(response);
}
})
}
Expand All @@ -49,7 +49,7 @@ function stubRequestAndServer(response, indexPatternSavedObjects = []) {
getSavedObjectsClient: function () {
return {
find: function () {
return Promise.resolve({
return Bluebird.resolve({
saved_objects: indexPatternSavedObjects
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/

import proxyquire from 'proxyquire';
import Promise from 'bluebird';
import Bluebird from 'bluebird';
const expect = require('chai').expect;

const graphiteResponse = function () {
return Promise.resolve({
return Bluebird.resolve({
json: function () {
return [{
target: '__beer__',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import proxyquire from 'proxyquire';
import Promise from 'bluebird';
import Bluebird from 'bluebird';
import assert from 'chai';
const expect = assert.expect;

Expand All @@ -41,7 +41,7 @@ describe(filename, function () {
params: parseQueryString(parseURL(url).query),
code: url.match(/datasets\/(.*).json/)[1]
};
return Promise.resolve({
return Bluebird.resolve({
json: function () {
return {
name: '__beer__',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

const fn = require(`../yaxis`);
import Promise from 'bluebird';
import Bluebird from 'bluebird';
const expect = require('chai').expect;
import invoke from './helpers/invoke_series_fn.js';

Expand All @@ -36,7 +36,7 @@ describe('yaxis.js', () => {
});

it('puts odd numbers of the left, even on the right, by default', () => {
return Promise.all([
return Bluebird.all([
invoke(fn, [seriesList, 1]).then((r) => {
expect(r.output.list[0]._global.yaxes[0].position).to.equal('left');
}),
Expand All @@ -50,7 +50,7 @@ describe('yaxis.js', () => {
});

it('it lets you override default positions', () => {
return Promise.all([
return Bluebird.all([
invoke(fn, [seriesList, 1, null, null, 'right']).then((r) => {
expect(r.output.list[0]._global.yaxes[0].position).to.equal('right');
}),
Expand All @@ -61,7 +61,7 @@ describe('yaxis.js', () => {
});

it('sets the minimum (default: no min)', () => {
return Promise.all([
return Bluebird.all([
invoke(fn, [seriesList, 1, null]).then((r) => {
expect(r.output.list[0]._global.yaxes[0].min).to.equal(null);
}),
Expand All @@ -72,7 +72,7 @@ describe('yaxis.js', () => {
});

it('sets the max (default: no max)', () => {
return Promise.all([
return Bluebird.all([
invoke(fn, [seriesList, 1, null]).then((r) => {
expect(r.output.list[0]._global.yaxes[0].max).to.equal(undefined);
}),
Expand All @@ -83,7 +83,7 @@ describe('yaxis.js', () => {
});

it('sets the units (default: no unit', () => {
return Promise.all([
return Bluebird.all([
invoke(fn, [seriesList, 1, null, null, null, null, null, null]).then((r) => {
expect(r.output.list[0]._global.yaxes[0].units).to.equal(undefined);
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { i18n } from '@kbn/i18n';
import _ from 'lodash';
import Datasource from '../lib/classes/datasource';
import Promise from 'bluebird';
import Bluebird from 'bluebird';

export default new Datasource ('static', {
aliases: ['value'],
Expand Down Expand Up @@ -63,7 +63,7 @@ export default new Datasource ('static', {
});
}

return Promise.resolve({
return Bluebird.resolve({
type: 'seriesList',
list: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { i18n } from '@kbn/i18n';
import _ from 'lodash';
import worldbank from './worldbank.js';
import Promise from 'bluebird';
import Bluebird from 'bluebird';
import Datasource from '../lib/classes/datasource';

export default new Datasource ('worldbank_indicators', {
Expand Down Expand Up @@ -73,7 +73,7 @@ export default new Datasource ('worldbank_indicators', {
return worldbank.timelionFn(wbArgs, tlConfig);
});

return Promise.map(seriesLists, function (seriesList) {
return Bluebird.map(seriesLists, function (seriesList) {
return seriesList.list[0];
}).then(function (list) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import Promise from 'bluebird';
import Bluebird from 'bluebird';
import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import $ from 'jquery';
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('VegaVisualizations', () => {

$el.find('canvas')[0].dispatchEvent(event);

await Promise.delay(10);
await Bluebird.delay(10);

let tooltip = document.getElementById('vega-kibana-tooltip');
expect(tooltip).to.be.ok();
Expand Down
6 changes: 3 additions & 3 deletions src/legacy/server/pid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import _ from 'lodash';
import Boom from 'boom';
import Promise from 'bluebird';
import Bluebird from 'bluebird';
import { unlinkSync as unlink } from 'fs';
const writeFile = Promise.promisify(require('fs').writeFile);
const writeFile = Bluebird.promisify(require('fs').writeFile);

export default Promise.method(function (kbnServer, server, config) {
export default Bluebird.method(function (kbnServer, server, config) {
const path = config.get('pid.file');
if (!path) return;

Expand Down
Loading

0 comments on commit 95f482d

Please sign in to comment.