-
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
Spaces NP Migration - Moving server to the LegacyAPI model #45382
Changes from 6 commits
3dcd3ef
f58b05d
115ea0c
1b619a6
4962e51
2e4f6f4
b4939e3
b2ed48f
940742d
1099e3f
6d26d9f
ea16257
87d7ae7
7ae92e2
3d8729b
abe5cb2
4c30bfc
81629bc
0a8ba3f
48b0091
42c617f
5770f84
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import * as Rx from 'rxjs'; | ||
import { resolve } from 'path'; | ||
import KbnServer, { Server } from 'src/legacy/server/kbn_server'; | ||
import { CoreSetup, PluginInitializerContext } from 'src/core/server'; | ||
import { createOptionalPlugin } from '../../server/lib/optional_plugin'; | ||
// @ts-ignore | ||
import { AuditLogger } from '../../server/lib/audit_logger'; | ||
|
@@ -16,14 +17,9 @@ import { getActiveSpace } from './server/lib/get_active_space'; | |
import { getSpaceSelectorUrl } from './server/lib/get_space_selector_url'; | ||
import { migrateToKibana660 } from './server/lib/migrations'; | ||
import { plugin } from './server/new_platform'; | ||
import { | ||
SpacesInitializerContext, | ||
SpacesCoreSetup, | ||
SpacesHttpServiceSetup, | ||
} from './server/new_platform/plugin'; | ||
import { initSpacesRequestInterceptors } from './server/lib/request_interceptors'; | ||
import { SecurityPlugin } from '../security'; | ||
import { SpacesServiceSetup } from './server/new_platform/spaces_service/spaces_service'; | ||
import { initSpaceSelectorView } from './server/routes/views'; | ||
|
||
export interface SpacesPlugin { | ||
getSpaceId: SpacesServiceSetup['getSpaceId']; | ||
|
@@ -122,8 +118,7 @@ export const spaces = (kibana: Record<string, any>) => | |
|
||
async init(server: Server) { | ||
const kbnServer = (server as unknown) as KbnServer; | ||
const initializerContext = ({ | ||
legacyConfig: server.config(), | ||
const initializerContext = { | ||
config: { | ||
create: () => { | ||
return Rx.of({ | ||
|
@@ -140,29 +135,15 @@ export const spaces = (kibana: Record<string, any>) => | |
); | ||
}, | ||
}, | ||
} as unknown) as SpacesInitializerContext; | ||
|
||
const spacesHttpService: SpacesHttpServiceSetup = { | ||
...kbnServer.newPlatform.setup.core.http, | ||
route: server.route.bind(server), | ||
}; | ||
} as PluginInitializerContext; | ||
|
||
const core: SpacesCoreSetup = { | ||
http: spacesHttpService, | ||
elasticsearch: kbnServer.newPlatform.setup.core.elasticsearch, | ||
savedObjects: server.savedObjects, | ||
usage: server.usage, | ||
tutorial: { | ||
addScopedTutorialContextFactory: server.addScopedTutorialContextFactory, | ||
const core: 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. Now that all legacy requirements have moved to |
||
...kbnServer.newPlatform.setup.core, | ||
http: { | ||
...kbnServer.newPlatform.setup.core.http, | ||
route: server.route, | ||
legrego marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
capabilities: { | ||
registerCapabilitiesModifier: server.registerCapabilitiesModifier, | ||
}, | ||
auditLogger: { | ||
create: (pluginId: string) => | ||
new AuditLogger(server, pluginId, server.config(), server.plugins.xpack_main.info), | ||
}, | ||
}; | ||
} as unknown) as CoreSetup; | ||
|
||
const plugins = { | ||
xpackMain: server.plugins.xpack_main, | ||
|
@@ -177,20 +158,31 @@ export const spaces = (kibana: Record<string, any>) => | |
spaces: this, | ||
}; | ||
|
||
const { spacesService, log } = await plugin(initializerContext).setup(core, plugins); | ||
const legacyRouter = server.route.bind(server); | ||
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. The only component that couldn't move into 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. Btw, aren't you registering routes in |
||
|
||
initSpacesRequestInterceptors({ | ||
config: initializerContext.legacyConfig, | ||
http: core.http, | ||
getHiddenUiAppById: server.getHiddenUiAppById, | ||
onPostAuth: handler => { | ||
server.ext('onPostAuth', handler); | ||
const { spacesService, registerLegacyAPI } = await plugin( | ||
initializerContext, | ||
legacyRouter | ||
).setup(core, plugins); | ||
|
||
registerLegacyAPI({ | ||
legacyConfig: server.config(), | ||
legrego marked this conversation as resolved.
Show resolved
Hide resolved
|
||
savedObjects: server.savedObjects, | ||
usage: server.usage, | ||
tutorial: { | ||
addScopedTutorialContextFactory: server.addScopedTutorialContextFactory, | ||
}, | ||
capabilities: { | ||
registerCapabilitiesModifier: server.registerCapabilitiesModifier, | ||
}, | ||
auditLogger: { | ||
create: (pluginId: string) => | ||
new AuditLogger(server, pluginId, server.config(), server.plugins.xpack_main.info), | ||
}, | ||
log, | ||
spacesService, | ||
xpackMain: plugins.xpackMain, | ||
}); | ||
|
||
initSpaceSelectorView(server); | ||
|
||
server.expose('getSpaceId', (request: any) => spacesService.getSpaceId(request)); | ||
server.expose('spaceIdToNamespace', spacesService.spaceIdToNamespace); | ||
server.expose('namespaceToSpaceId', spacesService.namespaceToSpaceId); | ||
|
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.
legacyConfig
moves toLegacyAPI.legacyConfig