-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Reporting/FieldFormats] expose setFieldFormats
and call from ReportingPlugin.start
#56563
Changes from 4 commits
74bb4d0
5aa5ab5
e96c2f8
9b048e4
54a27af
c9318ff
2e8e3fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,4 @@ | |
* under the License. | ||
*/ | ||
|
||
export * from './create_getter_setter'; | ||
export * from './create_kibana_utils_core'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export { Get, Set, createGetterSetter } from '../common'; |
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; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { PluginInitializerContext } from 'src/core/server'; | ||
import { ReportingPlugin as Plugin } from './plugin'; | ||
|
||
export const plugin = (context: PluginInitializerContext) => { | ||
return new Plugin(context); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { Legacy } from 'kibana'; | ||
import { PluginInitializerContext } from 'src/core/server'; | ||
import { PluginSetupContract as SecurityPluginSetup } from '../../../../plugins/security/server'; | ||
import { ReportingPluginSpecOptions } from '../types'; | ||
import { plugin } from './index'; | ||
import { LegacySetup, ReportingStartDeps } from './plugin'; | ||
|
||
const buildLegacyDependencies = ( | ||
server: Legacy.Server, | ||
reportingPlugin: ReportingPluginSpecOptions | ||
): LegacySetup => ({ | ||
config: server.config, | ||
info: server.info, | ||
route: server.route.bind(server), | ||
plugins: { | ||
elasticsearch: server.plugins.elasticsearch, | ||
xpack_main: server.plugins.xpack_main, | ||
reporting: reportingPlugin, | ||
}, | ||
savedObjects: server.savedObjects, | ||
uiSettingsServiceFactory: server.uiSettingsServiceFactory, | ||
}); | ||
|
||
export const legacyInit = async ( | ||
server: Legacy.Server, | ||
reportingPlugin: ReportingPluginSpecOptions | ||
) => { | ||
const coreSetup = server.newPlatform.setup.core; | ||
const pluginInstance = plugin(server.newPlatform.coreContext as PluginInitializerContext); | ||
|
||
await pluginInstance.setup(coreSetup, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have to await the result of setup? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do need a way to make sure that my plugin's Soon in the plugin class there will be a private field referenced in I don't have my mind settled yet on how to co-ordinate dependencies in setup and start, but I plan to have it outlined in an upcoming PR to provide more plugin dependencies to modules that aren't called from routes handlers. :) |
||
elasticsearch: coreSetup.elasticsearch, | ||
security: server.newPlatform.setup.plugins.security as SecurityPluginSetup, | ||
usageCollection: server.newPlatform.setup.plugins.usageCollection, | ||
__LEGACY: buildLegacyDependencies(server, reportingPlugin), | ||
}); | ||
|
||
// Schedule to call the "start" hook only after start dependencies are ready | ||
coreSetup.getStartServices().then(([core, plugins]) => | ||
pluginInstance.start(core, { | ||
data: (plugins as ReportingStartDeps).data, | ||
}) | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this has to be async anymore