-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] New Platform Migration - server (#38360)
* wip: pull out all server dependencies * create new platform plugin * shim newPlatform plugin into legacy init * update server tests for migration refactor * cleanup interfaces * Only add ML links for sample data sets if full license from - 38120 * update test and fix typescript errors * Remove unused types
- Loading branch information
1 parent
4526e2a
commit c47a0d5
Showing
35 changed files
with
640 additions
and
478 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* 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 { resolve } from 'path'; | ||
import { i18n } from '@kbn/i18n'; | ||
import KbnServer, { Server } from 'src/legacy/server/kbn_server'; | ||
import { plugin } from './server/new_platform'; | ||
import { | ||
MlInitializerContext, | ||
MlCoreSetup, | ||
MlHttpServiceSetup, | ||
} from './server/new_platform/plugin'; | ||
// @ts-ignore: could not find declaration file for module | ||
import mappings from './mappings'; | ||
|
||
interface MlServer extends Server { | ||
addAppLinksToSampleDataset: () => {}; | ||
} | ||
|
||
export const ml = (kibana: any) => { | ||
return new kibana.Plugin({ | ||
require: ['kibana', 'elasticsearch', 'xpack_main'], | ||
id: 'ml', | ||
configPrefix: 'xpack.ml', | ||
publicDir: resolve(__dirname, 'public'), | ||
|
||
uiExports: { | ||
app: { | ||
title: i18n.translate('xpack.ml.mlNavTitle', { | ||
defaultMessage: 'Machine Learning', | ||
}), | ||
description: i18n.translate('xpack.ml.mlNavDescription', { | ||
defaultMessage: 'Machine Learning for the Elastic Stack', | ||
}), | ||
icon: 'plugins/ml/ml.svg', | ||
euiIconType: 'machineLearningApp', | ||
main: 'plugins/ml/app', | ||
}, | ||
styleSheetPaths: resolve(__dirname, 'public/index.scss'), | ||
hacks: ['plugins/ml/hacks/toggle_app_link_in_nav'], | ||
savedObjectSchemas: { | ||
'ml-telemetry': { | ||
isNamespaceAgnostic: true, | ||
}, | ||
}, | ||
mappings, | ||
home: ['plugins/ml/register_feature'], | ||
injectDefaultVars(server: any) { | ||
const config = server.config(); | ||
return { | ||
mlEnabled: config.get('xpack.ml.enabled'), | ||
}; | ||
}, | ||
}, | ||
|
||
async init(server: MlServer) { | ||
const kbnServer = (server as unknown) as KbnServer; | ||
|
||
const initializerContext = ({ | ||
legacyConfig: server.config(), | ||
logger: { | ||
get(...contextParts: string[]) { | ||
return kbnServer.newPlatform.coreContext.logger.get('plugins', 'ml', ...contextParts); | ||
}, | ||
}, | ||
} as unknown) as MlInitializerContext; | ||
|
||
const mlHttpService: MlHttpServiceSetup = { | ||
...kbnServer.newPlatform.setup.core.http, | ||
route: server.route.bind(server), | ||
}; | ||
|
||
const core: MlCoreSetup = { | ||
addAppLinksToSampleDataset: server.addAppLinksToSampleDataset, | ||
injectUiAppVars: server.injectUiAppVars, | ||
http: mlHttpService, | ||
savedObjects: server.savedObjects, | ||
usage: server.usage, | ||
}; | ||
|
||
const plugins = { | ||
elasticsearch: server.plugins.elasticsearch, | ||
security: server.plugins.security, | ||
xpackMain: server.plugins.xpack_main, | ||
ml: this, | ||
}; | ||
|
||
plugin(initializerContext).setup(core, plugins); | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.