Skip to content

Commit

Permalink
[NP Kibana Migrations ] kibana plugin home (#50444)
Browse files Browse the repository at this point in the history
* [NP:Kibana:homeAPI] initializes a new plugin (WIP)

* Typing

* New plugin tutorials not needing server working

* Retains legacy tutorial registration and adds new route for new platform tutorial plugin registrations

* Adds comment on where to pre-register general non-plugin specific tutorials

* Converts TutorialsPlugin to TutorialsRegistry service in new Home plugin

* Changes call to location of registerTutorial in registerTutorials

* Adds console log for the home plugin that's returning an empty object

* Removes async from setup and start methods in the home plugin and the tutorials service

* Starts writing tests and creating mocks

* Adds basic tests for TutorialRegistry service

* Adds basic tests for TutorialRegistry service

* Adds test for route

* Adds mocks and tests for the home plugin

* Adds home plugin to security plugin and registers scoped tutorials service

* Removes incorrect addition to src core server

* Fixes type errors

* Deletes unused code

* Deletes duplicate golangMetricsSpecProvider registration

* Nests tutorials service in a tutorials key in the home plugin, changes api http routes for legacy platform and NP

* Changes url variable names
  • Loading branch information
TinaHeiligers committed Nov 18, 2019
1 parent 2df0684 commit 1af8459
Show file tree
Hide file tree
Showing 74 changed files with 865 additions and 123 deletions.
23 changes: 19 additions & 4 deletions src/legacy/core_plugins/kibana/public/home/load_tutorials.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,44 @@ import _ from 'lodash';
import { getServices } from './kibana_services';
import { i18n } from '@kbn/i18n';

const baseUrlLP = getServices().addBasePath('/api/kibana/home/tutorials_LP');
const baseUrl = getServices().addBasePath('/api/kibana/home/tutorials');
const headers = new Headers();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/json');
headers.append('kbn-xsrf', 'kibana');

let tutorials = [];
let tutorialsLegacyPlatform = [];
let tutorialsNewPlatform = [];
let tutorialsLoaded = false;

async function loadTutorials() {
try {
const response = await fetch(baseUrl, {
const responseLegacyPlatform = await fetch(baseUrlLP, {
method: 'get',
credentials: 'include',
headers: headers,
});
if (response.status >= 300) {
if (responseLegacyPlatform.status >= 300) {
throw new Error(i18n.translate('kbn.home.loadTutorials.requestFailedErrorMessage', {
defaultMessage: 'Request failed with status code: {status}', values: { status: response.status } }
defaultMessage: 'Request failed with status code: {status}', values: { status: responseLegacyPlatform.status } }
));
}
const responseNewPlatform = await fetch(baseUrl, {
method: 'get',
credentials: 'include',
headers: headers,
});
if (responseNewPlatform.status >= 300) {
throw new Error(i18n.translate('kbn.home.loadTutorials.requestFailedErrorMessage', {
defaultMessage: 'Request failed with status code: {status}', values: { status: responseNewPlatform.status } }
));
}

tutorials = await response.json();
tutorialsLegacyPlatform = await responseLegacyPlatform.json();
tutorialsNewPlatform = await responseNewPlatform.json();
tutorials = tutorialsLegacyPlatform.concat(tutorialsNewPlatform);
tutorialsLoaded = true;
} catch(err) {
getServices().toastNotifications.addDanger({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

export function registerTutorials(server) {
server.route({
path: '/api/kibana/home/tutorials',
path: '/api/kibana/home/tutorials_LP',
method: ['GET'],
handler: function (req) {
return server.getTutorials(req);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function aerospikeMetricsSpecProvider(server, context) {
export function aerospikeMetricsSpecProvider(context) {
const moduleName = 'aerospike';
return {
id: 'aerospikeMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions';

export function apacheLogsSpecProvider(server, context) {
export function apacheLogsSpecProvider(context) {
const moduleName = 'apache';
const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS'];
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function apacheMetricsSpecProvider(server, context) {
export function apacheMetricsSpecProvider(context) {
const moduleName = 'apache';
return {
id: 'apacheMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
onPremCloudInstructions,
} from '../../../common/tutorials/auditbeat_instructions';

export function auditbeatSpecProvider(server, context) {
export function auditbeatSpecProvider(context) {
const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS'];
return {
id: 'auditbeat',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function awsMetricsSpecProvider(server, context) {
export function awsMetricsSpecProvider(context) {
const moduleName = 'aws';
return {
id: 'awsMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function cephMetricsSpecProvider(server, context) {
export function cephMetricsSpecProvider(context) {
const moduleName = 'ceph';
return {
id: 'cephMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
onPremCloudInstructions,
} from '../../../common/tutorials/filebeat_instructions';

export function ciscoLogsSpecProvider(server, context) {
export function ciscoLogsSpecProvider(context) {
const moduleName = 'cisco';
const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS'];
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/functionbeat_instructions';

export function cloudwatchLogsSpecProvider(server, context) {
export function cloudwatchLogsSpecProvider(context) {
return {
id: 'cloudwatchLogs',
name: i18n.translate('kbn.server.tutorials.cloudwatchLogs.nameTitle', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function consulMetricsSpecProvider(server, context) {
export function consulMetricsSpecProvider(context) {
const moduleName = 'consul';
return {
id: 'consulMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function corednsMetricsSpecProvider(server, context) {
export function corednsMetricsSpecProvider(context) {
const moduleName = 'coredns';
return {
id: 'corednsMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function couchbaseMetricsSpecProvider(server, context) {
export function couchbaseMetricsSpecProvider(context) {
const moduleName = 'couchbase';
return {
id: 'couchbaseMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function couchdbMetricsSpecProvider(server, context) {
export function couchdbMetricsSpecProvider(context) {
const moduleName = 'couchdb';
return {
id: 'couchdbMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function dockerMetricsSpecProvider(server, context) {
export function dockerMetricsSpecProvider(context) {
const moduleName = 'docker';
return {
id: 'dockerMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function dropwizardMetricsSpecProvider(server, context) {
export function dropwizardMetricsSpecProvider(context) {
const moduleName = 'dropwizard';
return {
id: 'dropwizardMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions';

export function elasticsearchLogsSpecProvider(server, context) {
export function elasticsearchLogsSpecProvider(context) {
const moduleName = 'elasticsearch';
const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS'];
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function elasticsearchMetricsSpecProvider(server, context) {
export function elasticsearchMetricsSpecProvider(context) {
const moduleName = 'elasticsearch';
return {
id: 'elasticsearchMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
onPremCloudInstructions,
} from '../../../common/tutorials/filebeat_instructions';

export function envoyproxyLogsSpecProvider(server, context) {
export function envoyproxyLogsSpecProvider(context) {
const moduleName = 'envoyproxy';
const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS'];
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function etcdMetricsSpecProvider(server, context) {
export function etcdMetricsSpecProvider(context) {
const moduleName = 'etcd';
return {
id: 'etcdMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function golangMetricsSpecProvider(server, context) {
export function golangMetricsSpecProvider(context) {
const moduleName = 'golang';
return {
id: moduleName + 'Metrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function haproxyMetricsSpecProvider(server, context) {
export function haproxyMetricsSpecProvider(context) {
const moduleName = 'haproxy';
return {
id: 'haproxyMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions';

export function iisLogsSpecProvider(server, context) {
export function iisLogsSpecProvider(context) {
const moduleName = 'iis';
const platforms = ['WINDOWS'];
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
onPremCloudInstructions,
} from '../../../common/tutorials/filebeat_instructions';

export function iptablesLogsSpecProvider(server, context) {
export function iptablesLogsSpecProvider(context) {
const moduleName = 'iptables';
const platforms = ['DEB', 'RPM'];
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions';

export function kafkaLogsSpecProvider(server, context) {
export function kafkaLogsSpecProvider(context) {
const moduleName = 'kafka';
const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS'];
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function kafkaMetricsSpecProvider(server, context) {
export function kafkaMetricsSpecProvider(context) {
const moduleName = 'kafka';
return {
id: 'kafkaMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function kibanaMetricsSpecProvider(server, context) {
export function kibanaMetricsSpecProvider(context) {
const moduleName = 'kibana';
return {
id: 'kibanaMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function kubernetesMetricsSpecProvider(server, context) {
export function kubernetesMetricsSpecProvider(context) {
const moduleName = 'kubernetes';
return {
id: 'kubernetesMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions';

export function logstashLogsSpecProvider(server, context) {
export function logstashLogsSpecProvider(context) {
const moduleName = 'logstash';
const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS'];
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function logstashMetricsSpecProvider(server, context) {
export function logstashMetricsSpecProvider(context) {
const moduleName = 'logstash';
return {
id: moduleName + 'Metrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function memcachedMetricsSpecProvider(server, context) {
export function memcachedMetricsSpecProvider(context) {
const moduleName = 'memcached';
return {
id: 'memcachedMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function mongodbMetricsSpecProvider(server, context) {
export function mongodbMetricsSpecProvider(context) {
const moduleName = 'mongodb';
return {
id: 'mongodbMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function mssqlMetricsSpecProvider(server, context) {
export function mssqlMetricsSpecProvider(context) {
const moduleName = 'mssql';
return {
id: 'mssqlMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function muninMetricsSpecProvider(server, context) {
export function muninMetricsSpecProvider(context) {
const moduleName = 'munin';
return {
id: 'muninMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions';

export function mysqlLogsSpecProvider(server, context) {
export function mysqlLogsSpecProvider(context) {
const moduleName = 'mysql';
const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS'];
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function mysqlMetricsSpecProvider(server, context) {
export function mysqlMetricsSpecProvider(context) {
const moduleName = 'mysql';
return {
id: 'mysqlMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions';

export function natsLogsSpecProvider(server, context) {
export function natsLogsSpecProvider(context) {
const moduleName = 'nats';
const geoipRequired = false;
const uaRequired = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function natsMetricsSpecProvider(server, context) {
export function natsMetricsSpecProvider(context) {
const moduleName = 'nats';
return {
id: 'natsMetrics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions';

export function nginxLogsSpecProvider(server, context) {
export function nginxLogsSpecProvider(context) {
const moduleName = 'nginx';
const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS'];
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category';
import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions';

export function nginxMetricsSpecProvider(server, context) {
export function nginxMetricsSpecProvider(context) {
const moduleName = 'nginx';
return {
id: 'nginxMetrics',
Expand Down
Loading

0 comments on commit 1af8459

Please sign in to comment.