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

Expose Elasticsearch from start and deprecate from setup #59886

Merged
merged 4 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [CoreStart](./kibana-plugin-core-server.corestart.md) &gt; [elasticsearch](./kibana-plugin-core-server.corestart.elasticsearch.md)

## CoreStart.elasticsearch property

[ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md)

<b>Signature:</b>

```typescript
elasticsearch: ElasticsearchServiceStart;
```
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface CoreStart
| Property | Type | Description |
| --- | --- | --- |
| [capabilities](./kibana-plugin-core-server.corestart.capabilities.md) | <code>CapabilitiesStart</code> | [CapabilitiesStart](./kibana-plugin-core-server.capabilitiesstart.md) |
| [elasticsearch](./kibana-plugin-core-server.corestart.elasticsearch.md) | <code>ElasticsearchServiceStart</code> | [ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md) |
| [savedObjects](./kibana-plugin-core-server.corestart.savedobjects.md) | <code>SavedObjectsServiceStart</code> | [SavedObjectsServiceStart](./kibana-plugin-core-server.savedobjectsservicestart.md) |
| [uiSettings](./kibana-plugin-core-server.corestart.uisettings.md) | <code>UiSettingsServiceStart</code> | [UiSettingsServiceStart](./kibana-plugin-core-server.uisettingsservicestart.md) |

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

## ElasticsearchServiceSetup.adminClient property

A client for the `admin` cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md)<!-- -->.
> Warning: This API is now obsolete.
>
> Use [ElasticsearchServiceStart.legacy.client](./kibana-plugin-core-server.elasticsearchservicestart.legacy.md) instead.
>
> A client for the `admin` cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md)<!-- -->.
>
<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

## ElasticsearchServiceSetup.createClient property

Create application specific Elasticsearch cluster API client with customized config. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md)<!-- -->.
> Warning: This API is now obsolete.
>
> Use [ElasticsearchServiceStart.legacy.createClient](./kibana-plugin-core-server.elasticsearchservicestart.legacy.md) instead.
>
> Create application specific Elasticsearch cluster API client with customized config. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md)<!-- -->.
>
<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

## ElasticsearchServiceSetup.dataClient property

A client for the `data` cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md)<!-- -->.
> Warning: This API is now obsolete.
>
> Use [ElasticsearchServiceStart.legacy.client](./kibana-plugin-core-server.elasticsearchservicestart.legacy.md) instead.
>
> A client for the `data` cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md)<!-- -->.
>
<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface ElasticsearchServiceSetup

| Property | Type | Description |
| --- | --- | --- |
| [adminClient](./kibana-plugin-core-server.elasticsearchservicesetup.adminclient.md) | <code>IClusterClient</code> | A client for the <code>admin</code> cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md)<!-- -->. |
| [createClient](./kibana-plugin-core-server.elasticsearchservicesetup.createclient.md) | <code>(type: string, clientConfig?: Partial&lt;ElasticsearchClientConfig&gt;) =&gt; ICustomClusterClient</code> | Create application specific Elasticsearch cluster API client with customized config. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md)<!-- -->. |
| [dataClient](./kibana-plugin-core-server.elasticsearchservicesetup.dataclient.md) | <code>IClusterClient</code> | A client for the <code>data</code> cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md)<!-- -->. |
| [adminClient](./kibana-plugin-core-server.elasticsearchservicesetup.adminclient.md) | <code>IClusterClient</code> | |
| [createClient](./kibana-plugin-core-server.elasticsearchservicesetup.createclient.md) | <code>(type: string, clientConfig?: Partial&lt;ElasticsearchClientConfig&gt;) =&gt; ICustomClusterClient</code> | |
| [dataClient](./kibana-plugin-core-server.elasticsearchservicesetup.dataclient.md) | <code>IClusterClient</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md) &gt; [legacy](./kibana-plugin-core-server.elasticsearchservicestart.legacy.md)

## ElasticsearchServiceStart.legacy property

<b>Signature:</b>

```typescript
legacy: {
readonly createClient: (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => ICustomClusterClient;
readonly client: IClusterClient;
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md)

## ElasticsearchServiceStart interface


<b>Signature:</b>

```typescript
export interface ElasticsearchServiceStart
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [legacy](./kibana-plugin-core-server.elasticsearchservicestart.legacy.md) | <code>{</code><br/><code> readonly createClient: (type: string, clientConfig?: Partial&lt;ElasticsearchClientConfig&gt;) =&gt; ICustomClusterClient;</code><br/><code> readonly client: IClusterClient;</code><br/><code> }</code> | |

1 change: 1 addition & 0 deletions docs/development/core/server/kibana-plugin-core-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [DiscoveredPlugin](./kibana-plugin-core-server.discoveredplugin.md) | Small container object used to expose information about discovered plugins that may or may not have been started. |
| [ElasticsearchError](./kibana-plugin-core-server.elasticsearcherror.md) | |
| [ElasticsearchServiceSetup](./kibana-plugin-core-server.elasticsearchservicesetup.md) | |
| [ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md) | |
| [EnvironmentMode](./kibana-plugin-core-server.environmentmode.md) | |
| [ErrorHttpResponseOptions](./kibana-plugin-core-server.errorhttpresponseoptions.md) | HTTP response parameters |
| [FakeRequest](./kibana-plugin-core-server.fakerequest.md) | Fake request object created manually by Kibana plugins. |
Expand Down
8 changes: 4 additions & 4 deletions src/core/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
- [UI Exports](#ui-exports)
- [How to](#how-to)
- [Configure plugin](#configure-plugin)
- [Handle plugin configuration deprecations](#handle-plugin-config-deprecations)
- [Handle plugin configuration deprecations](#handle-plugin-configuration-deprecations)
- [Use scoped services](#use-scoped-services)
- [Declare a custom scoped service](#declare-a-custom-scoped-service)
- [Mock new platform services in tests](#mock-new-platform-services-in-tests)
Expand All @@ -55,7 +55,7 @@
- [Provide Legacy Platform API to the New platform plugin](#provide-legacy-platform-api-to-the-new-platform-plugin)
- [On the server side](#on-the-server-side)
- [On the client side](#on-the-client-side)
- [Updates an application navlink at runtime](#updates-an-app-navlink-at-runtime)
- [Updates an application navlink at runtime](#updates-an-application-navlink-at-runtime)
- [Logging config migration](#logging-config-migration)

Make no mistake, it is going to take a lot of work to move certain plugins to the new platform. Our target is to migrate the entire repo over to the new platform throughout 7.x and to remove the legacy plugin system no later than 8.0, and this is only possible if teams start on the effort now.
Expand Down Expand Up @@ -1199,13 +1199,13 @@ In server code, `core` can be accessed from either `server.newPlatform` or `kbnS
| `request.getBasePath()` | [`core.http.basePath.get`](/docs/development/core/server/kibana-plugin-server.httpservicesetup.basepath.md) | |
| `server.plugins.elasticsearch.getCluster('data')` | [`context.core.elasticsearch.dataClient`](/docs/development/core/server/kibana-plugin-server.iscopedclusterclient.md) | |
| `server.plugins.elasticsearch.getCluster('admin')` | [`context.core.elasticsearch.adminClient`](/docs/development/core/server/kibana-plugin-server.iscopedclusterclient.md) | |
| `server.plugins.elasticsearch.createCluster(...)` | [`core.elasticsearch.createClient`](/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.createclient.md) | |
| `server.plugins.elasticsearch.createCluster(...)` | [`core.elasticsearch.legacy.createClient`](/docs/development/core/server/kibana-plugin-server.elasticsearchservicestart.legacy.md) | |
| `server.savedObjects.setScopedSavedObjectsClientFactory` | [`core.savedObjects.setClientFactoryProvider`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md) | |
| `server.savedObjects.addScopedSavedObjectsClientWrapperFactory` | [`core.savedObjects.addClientWrapper`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md) | |
| `server.savedObjects.getSavedObjectsRepository` | [`core.savedObjects.createInternalRepository`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createinternalrepository.md) [`core.savedObjects.createScopedRepository`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createscopedrepository.md) | |
| `server.savedObjects.getScopedSavedObjectsClient` | [`core.savedObjects.getScopedClient`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.getscopedclient.md) | |
| `request.getSavedObjectsClient` | [`context.core.savedObjects.client`](/docs/development/core/server/kibana-plugin-server.requesthandlercontext.core.md) | |
| `request.getUiSettingsService` | [`context.uiSettings.client`](/docs/development/core/server/kibana-plugin-server.iuisettingsclient.md) | |
| `request.getUiSettingsService` | [`context.core.uiSettings.client`](/docs/development/core/server/kibana-plugin-server.iuisettingsclient.md) | |
| `kibana.Plugin.deprecations` | [Handle plugin configuration deprecations](#handle-plugin-config-deprecations) and [`PluginConfigDescriptor.deprecations`](docs/development/core/server/kibana-plugin-server.pluginconfigdescriptor.md) | Deprecations from New Platform are not applied to legacy configuration |
| `kibana.Plugin.savedObjectSchemas` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) |
| `kibana.Plugin.mappings` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) |
Expand Down
28 changes: 27 additions & 1 deletion src/core/server/elasticsearch/elasticsearch_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import { IClusterClient, ICustomClusterClient } from './cluster_client';
import { IScopedClusterClient } from './scoped_cluster_client';
import { ElasticsearchConfig } from './elasticsearch_config';
import { ElasticsearchService } from './elasticsearch_service';
import { InternalElasticsearchServiceSetup, ElasticsearchServiceSetup } from './types';
import {
InternalElasticsearchServiceSetup,
ElasticsearchServiceSetup,
ElasticsearchServiceStart,
} from './types';
import { NodesVersionCompatibility } from './version_check/ensure_es_version';

const createScopedClusterClientMock = (): jest.Mocked<IScopedClusterClient> => ({
Expand Down Expand Up @@ -63,6 +67,26 @@ const createSetupContractMock = () => {
return setupContract;
};

type MockedElasticSearchServiceStart = {
legacy: jest.Mocked<ElasticsearchServiceStart['legacy']>;
} & {
legacy: {
client: jest.Mocked<IClusterClient>;
};
};

const createStartContractMock = () => {
const startContract: MockedElasticSearchServiceStart = {
legacy: {
createClient: jest.fn(),
client: createClusterClientMock(),
},
};
startContract.legacy.createClient.mockReturnValue(createCustomClusterClientMock());
startContract.legacy.client.asScoped.mockReturnValue(createScopedClusterClientMock());
return startContract;
};

type MockedInternalElasticSearchServiceSetup = jest.Mocked<
InternalElasticsearchServiceSetup & {
adminClient: jest.Mocked<IClusterClient>;
Expand Down Expand Up @@ -95,6 +119,7 @@ const createMock = () => {
stop: jest.fn(),
};
mocked.setup.mockResolvedValue(createInternalSetupContractMock());
mocked.start.mockResolvedValueOnce(createStartContractMock());
mocked.stop.mockResolvedValue();
return mocked;
};
Expand All @@ -103,6 +128,7 @@ export const elasticsearchServiceMock = {
create: createMock,
createInternalSetup: createInternalSetupContractMock,
createSetup: createSetupContractMock,
createStart: createStartContractMock,
createClusterClient: createClusterClientMock,
createCustomClusterClient: createCustomClusterClientMock,
createScopedClusterClient: createScopedClusterClientMock,
Expand Down
Loading