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

[Code]: Migrate to new platform #34766

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions src/core/server/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export class Env {
resolve(this.homeDir, 'src', 'plugins'),
resolve(this.homeDir, 'plugins'),
resolve(this.homeDir, '..', 'kibana-extra'),
resolve(this.homeDir, 'x-pack', 'plugins'),
];

this.cliArgs = Object.freeze(options.cliArgs);
Expand Down
2 changes: 2 additions & 0 deletions src/core/server/plugins/plugins_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export class PluginsService implements CoreService<PluginsServiceSetup> {
.pipe(first())
.toPromise();

console.log(config)

const { error$, plugin$ } = discover(config, this.coreContext);
await this.handleDiscoveryErrors(error$);
await this.handleDiscoveredPlugins(plugin$);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/testbed/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Plugin {
return {
data$: this.initializerContext.config.create(TestBedConfig).pipe(
map(config => {
this.log.debug(`I've got value from my config: ${config.secret}`);
this.log.error(`I've got value from my config: ${config.secret}`);
return `Some exposed data derived from config: ${config.secret}`;
})
),
Expand Down
2 changes: 0 additions & 2 deletions x-pack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { dashboardMode } from './plugins/dashboard_mode';
import { logstash } from './plugins/logstash';
import { beats } from './plugins/beats_management';
import { apm } from './plugins/apm';
import { code } from './plugins/code';
import { maps } from './plugins/maps';
import { licenseManagement } from './plugins/license_management';
import { cloud } from './plugins/cloud';
Expand Down Expand Up @@ -56,7 +55,6 @@ module.exports = function (kibana) {
logstash(kibana),
beats(kibana),
apm(kibana),
code(kibana),
maps(kibana),
canvas(kibana),
licenseManagement(kibana),
Expand Down
75 changes: 0 additions & 75 deletions x-pack/plugins/code/index.ts

This file was deleted.

9 changes: 9 additions & 0 deletions x-pack/plugins/code/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "code",
"version": "8.0.0",
"requiredPlugins": [
],
"configPath": ["xpack", "code"],
"server": true,
"ui": true
}
4 changes: 4 additions & 0 deletions x-pack/plugins/code/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { PluginInitializer } from '../../../../src/core/public';
import { CodePlugin, CodePluginSetup } from './plugin';

export const plugin: PluginInitializer<CodePluginSetup> = () => new CodePlugin();
31 changes: 31 additions & 0 deletions x-pack/plugins/code/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Plugin, PluginSetupContext } from '../../../../src/core/public';

// export const code = (kibana: any) =>
// new kibana.Plugin({
// require: ['kibana', 'elasticsearch', 'xpack_main'],
// id: 'code',
// configPrefix: 'xpack.code',
// publicDir: resolve(__dirname, 'public'),

// uiExports: {
// app: {
// title: 'Code',
// main: 'plugins/code/app',
// euiIconType: 'codeApp',
// },
// styleSheetPaths: resolve(__dirname, 'public/index.scss'),
// },
// config(Joi: typeof JoiNamespace) {

// },
// init,
// });

export class CodePlugin implements Plugin<CodePluginSetup> {
public setup(core: PluginSetupContext, deps: {}) {
// eslint-disable-next-line no-console
console.log(`code plugin loaded`);
}
}

export type CodePluginSetup = ReturnType<CodePlugin['setup']>;
11 changes: 11 additions & 0 deletions x-pack/plugins/code/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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 { Plugin } from './plugin';

export const plugin = (initializerContext: PluginInitializerContext) =>
new Plugin(initializerContext);
100 changes: 100 additions & 0 deletions x-pack/plugins/code/server/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import moment from 'moment';
import { map } from 'rxjs/operators';

import { Logger, PluginInitializerContext, PluginName, PluginSetupContext } from '../../../../src/core/server';
import { schema, TypeOf } from '@kbn/config-schema';
import { init } from './init';


export class CodeConfig {
public static schema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
queueIndex: schema.string({ defaultValue: '.code_internal-worker-queue' }),
// 1 hour by default.
queueTimeout: schema.number({ defaultValue: moment.duration(1, 'hour').asMilliseconds() }),
// The frequency which update scheduler executes. 5 minutes by default.
updateFrequencyMs: schema.number({ defaultValue: moment.duration(5, 'minute').asMilliseconds() }),
// The frequency which index scheduler executes. 1 day by default.
indexFrequencyMs: schema.number({ defaultValue: moment.duration(1, 'day').asMilliseconds() }),
// The frequency which each repo tries to update. 1 hour by default.
updateRepoFrequencyMs: schema.number({ defaultValue: moment.duration(1, 'hour').asMilliseconds() }),
// The frequency which each repo tries to index. 1 day by default.
indexRepoFrequencyMs: schema.number({ defaultValue: moment.duration(1, 'day').asMilliseconds() }),
lsp: schema.object({
// timeout of a request
requestTimeoutMs: schema.number({ defaultValue: moment.duration(10, 'second').asMilliseconds() }),
// if we want the language server run in seperately
detach: schema.boolean({ defaultValue: false }),
// whether we want to show more language server logs
verbose: schema.boolean({ defaultValue: false }),
}),
repos: schema.arrayOf(schema.string(), { defaultValue: [] }),
security: schema.object({
enableMavenImport: schema.boolean({ defaultValue: true }),
enableGradleImport: schema.boolean({ defaultValue: false }),
installNodeDependency: schema.boolean({ defaultValue: true }),
gitHostWhitelist: schema.arrayOf(
schema.string(),
{
defaultValue: [
'github.com',
'gitlab.com',
'bitbucket.org',
'gitbox.apache.org',
'eclipse.org',
]}
),
gitProtocolWhitelist: schema.arrayOf(
schema.string(),
{ defaultValue: ['https', 'git', 'ssh'] }
)
}),
// max workspace folder for each language server
maxWorkspace: schema.number({ defaultValue: 5 }),
// Temp option to disable index scheduler.
disableIndexScheduler: schema.boolean({ defaultValue: true }),
// Global reference as optional feature for now
enableGlobalReference: schema.boolean({ defaultValue: false }),
codeNode: schema.boolean({ defaultValue: false }),
});

public readonly queueIndex: string;

constructor(config: TypeOf<typeof CodeConfig['schema']>) {
this.queueIndex = config.queueIndex;
}
}


export class Plugin {
private readonly log: Logger;

constructor(private readonly initializerContext: PluginInitializerContext) {
this.log = this.initializerContext.logger.get();
this.log.info('Code init');
}

public setup(setupContext: PluginSetupContext, deps: Record<PluginName, unknown>) {
this.log.info('Code setup');
this.log.error(
`Setting up TestBed with core contract [${Object.keys(setupContext)}] and deps [${Object.keys(
deps
)}]`
);

return {
data$: this.initializerContext.config.create(CodeConfig).pipe(
map(config => {
this.log.error(config.queueIndex);
// init(core.http.server, config )
return config.queueIndex;
})
)
}
}

public stop() {
this.log.info('Code stopped')
// called when plugin is torn down during Kibana's shutdown sequence
}
}