Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stack management apps] Deprecate "enabled" Kibana setting #114768

Merged
merged 31 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4ec0c8b
[Index management] Add ui.enabled kibana setting
sebelga Oct 13, 2021
8cfa25e
[Rolllup Add ui.enabled kibana setting
sebelga Oct 13, 2021
d58fd9c
[Snapshot and restore] Add ui.enabled kibana setting
sebelga Oct 13, 2021
d93ca8c
[UA] Align with other apps and use the "MAJOR_VERSION" constant
sebelga Oct 13, 2021
25bc566
[UA] Align with other apps and use the "MAJOR_VERSION" constant (2)
sebelga Oct 13, 2021
c7ac361
[UA] Add ui.enabled kibana setting
sebelga Oct 13, 2021
ed42009
[Console] Add ui.enabled kibana setting
sebelga Oct 14, 2021
020bbd7
Fix TS and i18n issues
sebelga Oct 14, 2021
cc60f00
[CCR] Add ui.enabled kibana setting
sebelga Oct 14, 2021
5fe7713
[ILM] Add deprecation for "enabled" setting
sebelga Oct 14, 2021
cf46649
[License management] Add deprecation for "enabled" setting
sebelga Oct 14, 2021
8f936a6
Fix i18n issue
sebelga Oct 14, 2021
d8b6909
Fix jest test
sebelga Oct 14, 2021
63df99c
[Remote clusters] Add deprecation for "enabled" setting
sebelga Oct 14, 2021
338488a
Fix i18n issue
sebelga Oct 14, 2021
8b932f4
Fix i18n issue
sebelga Oct 14, 2021
2fddef6
Fix TS issue
sebelga Oct 14, 2021
058a081
Merge remote-tracking branch 'upstream/master' into stack-managment-a…
sebelga Oct 18, 2021
972934e
Refactor to not extend schema and config objects
sebelga Oct 18, 2021
d7cb7e2
Fix TS issue
sebelga Oct 18, 2021
90f3227
Merge branch 'master' into stack-managment-apps-deprecate-enable
kibanamachine Oct 18, 2021
6813c6a
Improve deprecation message for console.proxyConfig and console.proxy…
sebelga Oct 18, 2021
29bf4c7
Merge branch 'stack-managment-apps-deprecate-enable' of github.com:se…
sebelga Oct 18, 2021
52739f8
Fix TS issue
sebelga Oct 18, 2021
83e0a7b
Add doc for the "<app>.ui.enabled" setting
sebelga Oct 18, 2021
183a1c3
Fix Console deprecations.
cjcenizal Oct 18, 2021
2e326e5
Add inline comments where we check if Console UI is enabled.
cjcenizal Oct 18, 2021
61b703e
Fix typo in docs.
cjcenizal Oct 18, 2021
596c605
Configure level and refine copy for other deprecations.
cjcenizal Oct 18, 2021
223d956
Merge branch 'master' into stack-managment-apps-deprecate-enable
kibanamachine Oct 18, 2021
d5e7e16
Merge branch 'master' into stack-managment-apps-deprecate-enable
kibanamachine Oct 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/plugins/console/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
*/

import './index.scss';
import { PluginInitializerContext } from 'src/core/public';

import { ConsoleUIPlugin } from './plugin';

export type { ConsoleUILocatorParams } from './plugin';
export type { ConsoleUILocatorParams, ConsolePluginSetup } from './types';

export { ConsoleUIPlugin as Plugin };

export function plugin() {
return new ConsoleUIPlugin();
export function plugin(ctx: PluginInitializerContext) {
return new ConsoleUIPlugin(ctx);
}
122 changes: 66 additions & 56 deletions src/plugins/console/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,77 +7,87 @@
*/

import { i18n } from '@kbn/i18n';
import { SerializableRecord } from '@kbn/utility-types';
import { Plugin, CoreSetup } from 'src/core/public';
import { Plugin, CoreSetup, PluginInitializerContext } from 'src/core/public';

import { FeatureCatalogueCategory } from '../../home/public';
import { AppSetupUIPluginDependencies } from './types';

export interface ConsoleUILocatorParams extends SerializableRecord {
loadFrom?: string;
}
import {
AppSetupUIPluginDependencies,
ClientConfigType,
ConsolePluginSetup,
ConsoleUILocatorParams,
} from './types';

export class ConsoleUIPlugin implements Plugin<void, void, AppSetupUIPluginDependencies> {
constructor(private ctx: PluginInitializerContext) {}

public setup(
{ notifications, getStartServices, http }: CoreSetup,
{ devTools, home, share, usageCollection }: AppSetupUIPluginDependencies
) {
if (home) {
home.featureCatalogue.register({
): ConsolePluginSetup {
const {
ui: { enabled: isConsoleUiEnabled },
} = this.ctx.config.get<ClientConfigType>();

if (isConsoleUiEnabled) {
if (home) {
home.featureCatalogue.register({
id: 'console',
title: i18n.translate('console.devToolsTitle', {
defaultMessage: 'Interact with the Elasticsearch API',
}),
description: i18n.translate('console.devToolsDescription', {
defaultMessage: 'Skip cURL and use a JSON interface to work with your data in Console.',
}),
icon: 'consoleApp',
path: '/app/dev_tools#/console',
showOnHomePage: false,
category: FeatureCatalogueCategory.ADMIN,
});
}

devTools.register({
id: 'console',
title: i18n.translate('console.devToolsTitle', {
defaultMessage: 'Interact with the Elasticsearch API',
}),
description: i18n.translate('console.devToolsDescription', {
defaultMessage: 'Skip cURL and use a JSON interface to work with your data in Console.',
order: 1,
title: i18n.translate('console.consoleDisplayName', {
defaultMessage: 'Console',
}),
icon: 'consoleApp',
path: '/app/dev_tools#/console',
showOnHomePage: false,
category: FeatureCatalogueCategory.ADMIN,
});
}
enableRouting: false,
mount: async ({ element }) => {
const [core] = await getStartServices();

devTools.register({
id: 'console',
order: 1,
title: i18n.translate('console.consoleDisplayName', {
defaultMessage: 'Console',
}),
enableRouting: false,
mount: async ({ element }) => {
const [core] = await getStartServices();
const {
i18n: { Context: I18nContext },
docLinks: { DOC_LINK_VERSION },
} = core;

const {
i18n: { Context: I18nContext },
docLinks: { DOC_LINK_VERSION },
} = core;
const { renderApp } = await import('./application');

const { renderApp } = await import('./application');
return renderApp({
http,
docLinkVersion: DOC_LINK_VERSION,
I18nContext,
notifications,
usageCollection,
element,
});
},
});

return renderApp({
http,
docLinkVersion: DOC_LINK_VERSION,
I18nContext,
notifications,
usageCollection,
element,
});
},
});
const locator = share.url.locators.create<ConsoleUILocatorParams>({
id: 'CONSOLE_APP_LOCATOR',
getLocation: async ({ loadFrom }) => {
return {
app: 'dev_tools',
path: `#/console${loadFrom ? `?load_from=${loadFrom}` : ''}`,
state: { loadFrom },
};
},
});

const locator = share.url.locators.create<ConsoleUILocatorParams>({
id: 'CONSOLE_APP_LOCATOR',
getLocation: async ({ loadFrom }) => {
return {
app: 'dev_tools',
path: `#/console${loadFrom ? `?load_from=${loadFrom}` : ''}`,
state: { loadFrom },
};
},
});
return { locator };
}

return { locator };
return {};
}

public start() {}
Expand Down
13 changes: 13 additions & 0 deletions src/plugins/console/public/types/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export interface ClientConfigType {
ui: {
enabled: boolean;
};
}
2 changes: 2 additions & 0 deletions src/plugins/console/public/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ export * from './core_editor';
export * from './token';
export * from './tokens_provider';
export * from './common';
export { ClientConfigType } from './config';
export { ConsoleUILocatorParams } from './locator';
12 changes: 12 additions & 0 deletions src/plugins/console/public/types/locator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { SerializableRecord } from '@kbn/utility-types';

export interface ConsoleUILocatorParams extends SerializableRecord {
loadFrom?: string;
}
8 changes: 7 additions & 1 deletion src/plugins/console/public/types/plugin_dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
import { HomePublicPluginSetup } from '../../../home/public';
import { DevToolsSetup } from '../../../dev_tools/public';
import { UsageCollectionSetup } from '../../../usage_collection/public';
import { SharePluginSetup } from '../../../share/public';
import { SharePluginSetup, LocatorPublic } from '../../../share/public';

import { ConsoleUILocatorParams } from './locator';

export interface AppSetupUIPluginDependencies {
home?: HomePublicPluginSetup;
devTools: DevToolsSetup;
share: SharePluginSetup;
usageCollection?: UsageCollectionSetup;
}

export interface ConsolePluginSetup {
locator?: LocatorPublic<ConsoleUILocatorParams>;
}
139 changes: 96 additions & 43 deletions src/plugins/console/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,122 @@
*/

import { SemVer } from 'semver';
import { i18n } from '@kbn/i18n';
import { get } from 'lodash';
import { schema, TypeOf } from '@kbn/config-schema';
import { PluginConfigDescriptor } from 'kibana/server';
import { PluginConfigDescriptor, AddConfigDeprecation } from 'kibana/server';

import { MAJOR_VERSION } from '../common/constants';

const kibanaVersion = new SemVer(MAJOR_VERSION);

const baseSettings = {
enabled: schema.boolean({ defaultValue: true }),
ssl: schema.object({ verify: schema.boolean({ defaultValue: false }) }, {}),
const baseConfig = {
exposeToBrowser: {
ui: true,
},
};

// Settings only available in 7.x
const deprecatedSettings = {
proxyFilter: schema.arrayOf(schema.string(), { defaultValue: ['.*'] }),
proxyConfig: schema.arrayOf(
schema.object({
match: schema.object({
protocol: schema.string({ defaultValue: '*' }),
host: schema.string({ defaultValue: '*' }),
port: schema.string({ defaultValue: '*' }),
path: schema.string({ defaultValue: '*' }),
}),

timeout: schema.number(),
ssl: schema.object(
{
verify: schema.boolean(),
ca: schema.arrayOf(schema.string()),
cert: schema.string(),
key: schema.string(),
},
{ defaultValue: undefined }
),
}),
{ defaultValue: [] }
),
const baseSchema = {
ssl: schema.object({ verify: schema.boolean({ defaultValue: false }) }, {}),
ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
};

// >= 8.x
const configSchema = schema.object(
{
...baseSettings,
...baseSchema,
},
{ defaultValue: undefined }
);

// Settings that will be deprecated in the next major
const deprecations: PluginConfigDescriptor['deprecations'] = () => [];

// Config in latest major
const configLatest: PluginConfigDescriptor<ConsoleConfig> = {
...baseConfig,
schema: configSchema,
deprecations,
};

export type ConsoleConfig = TypeOf<typeof configSchema>;

// 7.x
const configSchema7x = schema.object(
{
...baseSettings,
...deprecatedSettings,
...baseSchema,
enabled: schema.boolean({ defaultValue: true }),
proxyFilter: schema.arrayOf(schema.string(), { defaultValue: ['.*'] }),
proxyConfig: schema.arrayOf(
schema.object({
match: schema.object({
protocol: schema.string({ defaultValue: '*' }),
host: schema.string({ defaultValue: '*' }),
port: schema.string({ defaultValue: '*' }),
path: schema.string({ defaultValue: '*' }),
}),

timeout: schema.number(),
ssl: schema.object(
{
verify: schema.boolean(),
ca: schema.arrayOf(schema.string()),
cert: schema.string(),
key: schema.string(),
},
{ defaultValue: undefined }
),
}),
{ defaultValue: [] }
),
},
{ defaultValue: undefined }
);

export type ConfigType = TypeOf<typeof configSchema>;
export type ConfigType7x = TypeOf<typeof configSchema7x>;

export const config: PluginConfigDescriptor<ConfigType | ConfigType7x> = {
schema: kibanaVersion.major < 8 ? configSchema7x : configSchema,
deprecations: ({ deprecate, unused }) => [
deprecate('enabled', '8.0.0'),
deprecate('proxyFilter', '8.0.0'),
deprecate('proxyConfig', '8.0.0'),
unused('ssl'),
],
// Settings that will be deprecated in 8.0
const deprecations7x: PluginConfigDescriptor<ConsoleConfig7x>['deprecations'] = ({
deprecate,
unused,
}) => [
deprecate('proxyFilter', '8.0.0'),
deprecate('proxyConfig', '8.0.0'),
unused('ssl'),
(completeConfig: Record<string, any>, rootPath: string, addDeprecation: AddConfigDeprecation) => {
if (get(completeConfig, 'console.enabled') === undefined) {
return completeConfig;
}

addDeprecation({
title: i18n.translate('console.deprecations.enabledTitle', {
defaultMessage: 'Setting "console.enabled" is deprecated',
}),
message: i18n.translate('console.deprecations.enabledMessage', {
defaultMessage: 'Use the "console.ui.enabled" setting instead of "console.enabled".',
}),
correctiveActions: {
manualSteps: [
i18n.translate('console.deprecations.enabled.manualStepOneMessage', {
defaultMessage: 'Open the kibana.yml config file.',
}),
i18n.translate('console.deprecations.enabled.manualStepTwoMessage', {
defaultMessage: 'Change the "console.enabled" setting to "console.ui.enabled".',
}),
],
},
});
return completeConfig;
},
];

export type ConsoleConfig7x = TypeOf<typeof configSchema7x>;

const config7x: PluginConfigDescriptor<ConsoleConfig7x> = {
...baseConfig,
schema: configSchema7x,
deprecations: deprecations7x,
};

export const config: PluginConfigDescriptor<ConsoleConfig | ConsoleConfig7x> =
kibanaVersion.major < 8 ? config7x : configLatest;
1 change: 1 addition & 0 deletions src/plugins/console/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { PluginInitializerContext } from 'kibana/server';
import { ConsoleServerPlugin } from './plugin';

export { ConsoleSetup, ConsoleStart } from './types';

export { config } from './config';

export const plugin = (ctx: PluginInitializerContext) => new ConsoleServerPlugin(ctx);
Loading