Skip to content

Commit

Permalink
remove legacy core deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Dec 10, 2019
1 parent 46b7532 commit b9e0c6c
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 377 deletions.
3 changes: 1 addition & 2 deletions src/cli/cluster/cluster_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ import { REPO_ROOT } from '@kbn/dev-utils';
import Log from '../log';
import Worker from './worker';
import { Config } from '../../legacy/server/config/config';
import { transformDeprecations } from '../../legacy/server/config/transform_deprecations';

process.env.kbnWorkerType = 'managr';

export default class ClusterManager {
static create(opts, settings = {}, basePathProxy) {
return new ClusterManager(
opts,
Config.withDefaultSchema(transformDeprecations(settings)),
Config.withDefaultSchema(settings),
basePathProxy
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('ensureValidConfiguration', () => {
coreHandledConfigPaths: ['core', 'elastic'],
pluginSpecs: 'pluginSpecs',
disabledPluginSpecs: 'disabledPluginSpecs',
inputSettings: 'settings',
settings: 'settings',
legacyConfig: 'pluginExtendedConfig',
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function ensureValidConfiguration(
coreHandledConfigPaths: await configService.getUsedPaths(),
pluginSpecs,
disabledPluginSpecs,
inputSettings: settings,
settings,
legacyConfig: pluginExtendedConfig,
});

Expand Down
67 changes: 10 additions & 57 deletions src/core/server/legacy/config/get_unused_config_keys.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,10 @@
import { LegacyPluginSpec } from '../plugins/find_legacy_plugin_specs';
import { LegacyConfig } from './types';
import { getUnusedConfigKeys } from './get_unused_config_keys';
// @ts-ignore
import { transformDeprecations } from '../../../../legacy/server/config/transform_deprecations';

jest.mock('../../../../legacy/server/config/transform_deprecations', () => ({
transformDeprecations: jest.fn().mockImplementation(s => s),
}));

describe('getUnusedConfigKeys', () => {
beforeEach(() => {
jest.resetAllMocks();
transformDeprecations.mockImplementation((s: any) => s);
});

const getConfig = (values: Record<string, any> = {}): LegacyConfig =>
Expand All @@ -45,7 +38,7 @@ describe('getUnusedConfigKeys', () => {
coreHandledConfigPaths: [],
pluginSpecs: [],
disabledPluginSpecs: [],
inputSettings: {},
settings: {},
legacyConfig: getConfig(),
})
).toEqual([]);
Expand All @@ -57,7 +50,7 @@ describe('getUnusedConfigKeys', () => {
coreHandledConfigPaths: [],
pluginSpecs: [],
disabledPluginSpecs: [],
inputSettings: {
settings: {
presentInBoth: true,
alsoInBoth: 'someValue',
},
Expand All @@ -75,7 +68,7 @@ describe('getUnusedConfigKeys', () => {
coreHandledConfigPaths: [],
pluginSpecs: [],
disabledPluginSpecs: [],
inputSettings: {
settings: {
presentInBoth: true,
},
legacyConfig: getConfig({
Expand All @@ -92,7 +85,7 @@ describe('getUnusedConfigKeys', () => {
coreHandledConfigPaths: [],
pluginSpecs: [],
disabledPluginSpecs: [],
inputSettings: {
settings: {
presentInBoth: true,
onlyInSetting: 'value',
},
Expand All @@ -109,7 +102,7 @@ describe('getUnusedConfigKeys', () => {
coreHandledConfigPaths: [],
pluginSpecs: [],
disabledPluginSpecs: [],
inputSettings: {
settings: {
elasticsearch: {
username: 'foo',
password: 'bar',
Expand All @@ -131,7 +124,7 @@ describe('getUnusedConfigKeys', () => {
coreHandledConfigPaths: [],
pluginSpecs: [],
disabledPluginSpecs: [],
inputSettings: {
settings: {
env: 'development',
},
legacyConfig: getConfig({
Expand All @@ -149,7 +142,7 @@ describe('getUnusedConfigKeys', () => {
coreHandledConfigPaths: [],
pluginSpecs: [],
disabledPluginSpecs: [],
inputSettings: {
settings: {
prop: ['a', 'b', 'c'],
},
legacyConfig: getConfig({
Expand All @@ -171,7 +164,7 @@ describe('getUnusedConfigKeys', () => {
getConfigPrefix: () => 'foo.bar',
} as unknown) as LegacyPluginSpec,
],
inputSettings: {
settings: {
foo: {
bar: {
unused: true,
Expand All @@ -194,7 +187,7 @@ describe('getUnusedConfigKeys', () => {
coreHandledConfigPaths: ['core', 'foo.bar'],
pluginSpecs: [],
disabledPluginSpecs: [],
inputSettings: {
settings: {
core: {
prop: 'value',
},
Expand All @@ -209,46 +202,6 @@ describe('getUnusedConfigKeys', () => {
});

describe('using deprecation', () => {
it('calls transformDeprecations with the settings', async () => {
await getUnusedConfigKeys({
coreHandledConfigPaths: [],
pluginSpecs: [],
disabledPluginSpecs: [],
inputSettings: {
prop: 'settings',
},
legacyConfig: getConfig({
prop: 'config',
}),
});
expect(transformDeprecations).toHaveBeenCalledTimes(1);
expect(transformDeprecations).toHaveBeenCalledWith({
prop: 'settings',
});
});

it('uses the transformed settings', async () => {
transformDeprecations.mockImplementation((settings: Record<string, any>) => {
delete settings.deprecated;
settings.updated = 'new value';
return settings;
});
expect(
await getUnusedConfigKeys({
coreHandledConfigPaths: [],
pluginSpecs: [],
disabledPluginSpecs: [],
inputSettings: {
onlyInSettings: 'bar',
deprecated: 'value',
},
legacyConfig: getConfig({
updated: 'config',
}),
})
).toEqual(['onlyInSettings']);
});

it('should use the plugin deprecations provider', async () => {
expect(
await getUnusedConfigKeys({
Expand All @@ -262,7 +215,7 @@ describe('getUnusedConfigKeys', () => {
} as unknown) as LegacyPluginSpec,
],
disabledPluginSpecs: [],
inputSettings: {
settings: {
foo: {
foo: 'dolly',
foo1: 'bar',
Expand Down
9 changes: 2 additions & 7 deletions src/core/server/legacy/config/get_unused_config_keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import { difference, get, set } from 'lodash';
// @ts-ignore
import { transformDeprecations } from '../../../../legacy/server/config/transform_deprecations';
// @ts-ignore
import { getTransform } from '../../../../legacy/deprecation/index';
import { unset, getFlattenedObject } from '../../../../legacy/utils';
import { hasConfigPathIntersection } from '../../config';
Expand All @@ -33,18 +31,15 @@ export async function getUnusedConfigKeys({
coreHandledConfigPaths,
pluginSpecs,
disabledPluginSpecs,
inputSettings,
settings,
legacyConfig,
}: {
coreHandledConfigPaths: string[];
pluginSpecs: LegacyPluginSpec[];
disabledPluginSpecs: LegacyPluginSpec[];
inputSettings: Record<string, any>;
settings: Record<string, any>;
legacyConfig: LegacyConfig;
}) {
// transform deprecated core settings
const settings = transformDeprecations(inputSettings);

// transform deprecated plugin settings
for (let i = 0; i < pluginSpecs.length; i++) {
const spec = pluginSpecs[i];
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/legacy/logging/legacy_logging_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { ServerExtType } from 'hapi';
import Podium from 'podium';
// @ts-ignore: implicit any for JS file
import { Config, transformDeprecations } from '../../../../legacy/server/config';
import { Config } from '../../../../legacy/server/config';
// @ts-ignore: implicit any for JS file
import { setupLogging } from '../../../../legacy/server/logging';
import { LogLevel } from '../../logging/log_level';
Expand Down Expand Up @@ -99,7 +99,7 @@ export class LegacyLoggingServer {
ops: { interval: 2147483647 },
};

setupLogging(this, Config.withDefaultSchema(transformDeprecations(config)));
setupLogging(this, Config.withDefaultSchema(config));
}

public register({ plugin: { register }, options }: PluginRegisterParams): Promise<void> {
Expand Down
6 changes: 2 additions & 4 deletions src/legacy/plugin_discovery/find_plugin_specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import * as Rx from 'rxjs';
import { distinct, toArray, mergeMap, share, shareReplay, filter, last, map, tap } from 'rxjs/operators';
import { realpathSync } from 'fs';

import { transformDeprecations, Config } from '../server/config';
import { Config } from '../server/config';

import {
extendConfigService,
Expand All @@ -40,9 +40,7 @@ import {
} from './errors';

export function defaultConfig(settings) {
return Config.withDefaultSchema(
transformDeprecations(settings)
);
return Config.withDefaultSchema(settings);
}

function bufferAllResults(observable) {
Expand Down
3 changes: 1 addition & 2 deletions src/legacy/plugin_discovery/plugin_config/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import { get } from 'lodash';

import * as serverConfig from '../../server/config';
import { getTransform } from '../../deprecation';

/**
Expand All @@ -33,7 +32,7 @@ import { getTransform } from '../../deprecation';
*/
export async function getSettings(spec, rootSettings, logDeprecation) {
const prefix = spec.getConfigPrefix();
const rawSettings = get(serverConfig.transformDeprecations(rootSettings), prefix);
const rawSettings = get(rootSettings, prefix);
const transform = await getTransform(spec);
return transform(rawSettings, logDeprecation);
}
1 change: 0 additions & 1 deletion src/legacy/server/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
* under the License.
*/

export { transformDeprecations } from './transform_deprecations';
export { Config } from './config';
116 changes: 0 additions & 116 deletions src/legacy/server/config/transform_deprecations.js

This file was deleted.

Loading

0 comments on commit b9e0c6c

Please sign in to comment.