Skip to content

Commit

Permalink
Extract License service from CCR and Watcher into license_api_guard p…
Browse files Browse the repository at this point in the history
…lugin in x-pack (#95973) (#97332)

* Localize error messages.
# Conflicts:
#	.github/CODEOWNERS
  • Loading branch information
cjcenizal authored Apr 16, 2021
1 parent 034a952 commit 84d8a7d
Show file tree
Hide file tree
Showing 57 changed files with 431 additions and 339 deletions.
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ the infrastructure monitoring use-case within Kibana.
|Visualization editor allowing to quickly and easily configure compelling visualizations to use on dashboards and canvas workpads.
|{kib-repo}blob/{branch}/x-pack/plugins/license_api_guard[licenseApiGuard]
|WARNING: Missing README.
|{kib-repo}blob/{branch}/x-pack/plugins/license_management/README.md[licenseManagement]
|This plugin enables users to activate a trial license, downgrade to Basic, and upload a new license.
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/es_ui_shared/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../data/tsconfig.json" },
{ "path": "../data/tsconfig.json" }
]
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
{ "path": "./x-pack/plugins/infra/tsconfig.json" },
{ "path": "./x-pack/plugins/ingest_pipelines/tsconfig.json" },
{ "path": "./x-pack/plugins/lens/tsconfig.json" },
{ "path": "./x-pack/plugins/license_api_guard/tsconfig.json" },
{ "path": "./x-pack/plugins/license_management/tsconfig.json" },
{ "path": "./x-pack/plugins/licensing/tsconfig.json" },
{ "path": "./x-pack/plugins/logstash/tsconfig.json" },
Expand Down
1 change: 1 addition & 0 deletions x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"xpack.fleet": "plugins/fleet",
"xpack.ingestPipelines": "plugins/ingest_pipelines",
"xpack.lens": "plugins/lens",
"xpack.licenseApiGuard": "plugins/license_api_guard",
"xpack.licenseMgmt": "plugins/license_management",
"xpack.licensing": "plugins/licensing",
"xpack.lists": "plugins/lists",
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/cross_cluster_replication/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"requiredPlugins": [
"home",
"licensing",
"licenseApiGuard",
"management",
"remoteClusters",
"indexManagement",
Expand Down
37 changes: 15 additions & 22 deletions x-pack/plugins/cross_cluster_replication/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import { Observable } from 'rxjs';
import { first } from 'rxjs/operators';
import { i18n } from '@kbn/i18n';
import {
CoreSetup,
CoreStart,
ILegacyCustomClusterClient,
Plugin,
Logger,
Expand All @@ -19,12 +19,11 @@ import {

import { Index } from '../../index_management/server';
import { PLUGIN } from '../common/constants';
import type { Dependencies, CcrRequestHandlerContext } from './types';
import { SetupDependencies, StartDependencies, CcrRequestHandlerContext } from './types';
import { registerApiRoutes } from './routes';
import { License } from './services';
import { elasticsearchJsPlugin } from './client/elasticsearch_ccr';
import { CrossClusterReplicationConfig } from './config';
import { isEsError } from './shared_imports';
import { License, isEsError } from './shared_imports';
import { formatEsError } from './lib/format_es_error';

async function getCustomEsClient(getStartServices: CoreSetup['getStartServices']) {
Expand Down Expand Up @@ -77,7 +76,7 @@ export class CrossClusterReplicationServerPlugin implements Plugin<void, void, a

setup(
{ http, getStartServices }: CoreSetup,
{ features, licensing, indexManagement, remoteClusters }: Dependencies
{ features, licensing, indexManagement, remoteClusters }: SetupDependencies
) {
this.config$
.pipe(first())
Expand All @@ -97,22 +96,10 @@ export class CrossClusterReplicationServerPlugin implements Plugin<void, void, a
}
});

this.license.setup(
{
pluginId: PLUGIN.ID,
minimumLicenseType: PLUGIN.minimumLicenseType,
defaultErrorMessage: i18n.translate(
'xpack.crossClusterReplication.licenseCheckErrorMessage',
{
defaultMessage: 'License check failed',
}
),
},
{
licensing,
logger: this.logger,
}
);
this.license.setup({
pluginName: PLUGIN.TITLE,
logger: this.logger,
});

features.registerElasticsearchFeature({
id: 'cross_cluster_replication',
Expand Down Expand Up @@ -147,7 +134,13 @@ export class CrossClusterReplicationServerPlugin implements Plugin<void, void, a
});
}

start() {}
start(core: CoreStart, { licensing }: StartDependencies) {
this.license.start({
pluginId: PLUGIN.ID,
minimumLicenseType: PLUGIN.minimumLicenseType,
licensing,
});
}

stop() {
if (this.ccrEsClient) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerCreateRoute } from './register_create_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerDeleteRoute } from './register_delete_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerFetchRoute } from './register_fetch_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerGetRoute } from './register_get_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerPauseRoute } from './register_pause_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerResumeRoute } from './register_resume_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerUpdateRoute } from './register_update_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerCreateRoute } from './register_create_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerFetchRoute } from './register_fetch_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerGetRoute } from './register_get_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerPauseRoute } from './register_pause_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerResumeRoute } from './register_resume_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
import { kibanaResponseFactory, RequestHandler } from 'src/core/server';

import { isEsError } from '../../../shared_imports';
import { isEsError, License } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
import { License } from '../../../services';
import { mockRouteContext } from '../test_lib';
import { registerUnfollowRoute } from './register_unfollow_route';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
* 2.0.
*/

export { License } from './license';
export { addBasePath } from './add_base_path';

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
*/

export { isEsError } from '../../../../src/plugins/es_ui_shared/server';
export { License } from '../../license_api_guard/server';
11 changes: 7 additions & 4 deletions x-pack/plugins/cross_cluster_replication/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,23 @@

import { IRouter, ILegacyScopedClusterClient, RequestHandlerContext } from 'src/core/server';
import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server';
import { LicensingPluginSetup } from '../../licensing/server';
import { LicensingPluginSetup, LicensingPluginStart } from '../../licensing/server';
import { IndexManagementPluginSetup } from '../../index_management/server';
import { RemoteClustersPluginSetup } from '../../remote_clusters/server';
import { License } from './services';
import { isEsError } from './shared_imports';
import { License, isEsError } from './shared_imports';
import { formatEsError } from './lib/format_es_error';

export interface Dependencies {
export interface SetupDependencies {
licensing: LicensingPluginSetup;
indexManagement: IndexManagementPluginSetup;
remoteClusters: RemoteClustersPluginSetup;
features: FeaturesPluginSetup;
}

export interface StartDependencies {
licensing: LicensingPluginStart;
}

export interface RouteDependencies {
router: CcrPluginRouter;
license: License;
Expand Down
Loading

0 comments on commit 84d8a7d

Please sign in to comment.