Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ingest-overview-page
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Harding committed Apr 17, 2020
2 parents 49be45b + 2af91b3 commit ac44be3
Show file tree
Hide file tree
Showing 730 changed files with 12,942 additions and 48,759 deletions.
4 changes: 2 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ bower_components
/built_assets
/html_docs
/src/plugins/data/common/es_query/kuery/ast/_generated_/**
/src/legacy/core_plugins/vis_type_timelion/public/_generated_/**
/src/plugins/vis_type_timelion/public/_generated_/**
src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data
/src/legacy/ui/public/flot-charts
/test/fixtures/scenarios
/src/legacy/core_plugins/console/public/webpackShims
/src/legacy/core_plugins/console/public/tests/webpackShims
/src/legacy/ui/public/utils/decode_geo_hash.js
/src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.*
/src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.*
/src/core/lib/kbn_internal_native_observable
/packages/*/target
/packages/eslint-config-kibana
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/src/legacy/core_plugins/vis_type_vislib/ @elastic/kibana-app
/src/plugins/vis_type_xy/ @elastic/kibana-app
/src/plugins/kibana_legacy/ @elastic/kibana-app
/src/plugins/timelion/ @elastic/kibana-app
/src/plugins/vis_type_timelion/ @elastic/kibana-app
/src/plugins/dashboard/ @elastic/kibana-app
/src/plugins/discover/ @elastic/kibana-app
/src/plugins/visualize/ @elastic/kibana-app
Expand Down
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"src/plugins/telemetry_management_section"
],
"tileMap": "src/legacy/core_plugins/tile_map",
"timelion": ["src/legacy/core_plugins/timelion", "src/legacy/core_plugins/vis_type_timelion", "src/plugins/timelion"],
"timelion": ["src/legacy/core_plugins/timelion", "src/plugins/vis_type_timelion"],
"uiActions": "src/plugins/ui_actions",
"visDefaultEditor": "src/plugins/vis_default_editor",
"visTypeMarkdown": "src/plugins/vis_type_markdown",
Expand Down
4 changes: 2 additions & 2 deletions docs/api/saved-objects/create.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ any data that you send to the API is properly formed.

[source,sh]
--------------------------------------------------
$ curl -X POST "localhost:5601/api/saved_objects/index-pattern/my-pattern"
$ curl -X POST "localhost:5601/api/saved_objects/index-pattern/my-pattern" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '
{
"attributes": {
"title": "my-pattern-*"
}
}
}'
--------------------------------------------------
// KIBANA

Expand Down
16 changes: 8 additions & 8 deletions docs/api/saved-objects/export.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,46 +68,46 @@ Export all index pattern saved objects:

[source,sh]
--------------------------------------------------
$ curl -X POST "localhost:5601/api/saved_objects/_export"
$ curl -X POST "localhost:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '
{
"type": "index-pattern"
}
}'
--------------------------------------------------
// KIBANA

Export all index pattern saved objects and exclude the export summary from the stream:

[source,sh]
--------------------------------------------------
$ curl -X POST "localhost:5601/api/saved_objects/_export"
$ curl -X POST "localhost:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '
{
"type": "index-pattern",
"excludeExportDetails": true
}
}'
--------------------------------------------------
// KIBANA

Export a specific saved object:

[source,sh]
--------------------------------------------------
$ curl -X POST "localhost:5601/api/saved_objects/_export"
$ curl -X POST "localhost:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '
{
"objects": [
{
"type": "dashboard",
"id": "be3733a0-9efe-11e7-acb3-3dab96693fab"
}
]
}
}'
--------------------------------------------------
// KIBANA

Export a specific saved object and it's related objects :

[source,sh]
--------------------------------------------------
$ curl -X POST "localhost:5601/api/saved_objects/_export"
$ curl -X POST "localhost:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '
{
"objects": [
{
Expand All @@ -116,6 +116,6 @@ $ curl -X POST "localhost:5601/api/saved_objects/_export"
}
],
"includeReferencesDeep": true
}
}'
--------------------------------------------------
// KIBANA
7 changes: 7 additions & 0 deletions docs/ingest_manager/index-templates.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Elasticsearch Index Templates

## Generation

* Index templates are generated from `YAML` files contained in the package.
* There is one index template per dataset.
* For the generation of an index template, all `yml` files contained in the package subdirectory `dataset/DATASET_NAME/fields/` are used.
7 changes: 7 additions & 0 deletions docs/ingest_manager/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,10 @@ The new ingest pipeline is expected to still work with the data coming from olde
In case of a breaking change in the data structure, the new ingest pipeline is also expected to deal with this change. In case there are breaking changes which cannot be dealt with in an ingest pipeline, a new package has to be created.

Each package lists its minimal required agent version. In case there are agents enrolled with an older version, the user is notified to upgrade these agents as otherwise the new configs cannot be rolled out.

=== Generated assets

When a package is installed or upgraded, certain Kibana and Elasticsearch assets are generated from . These follow the naming conventions explained above (see "indexing strategy") and contain configuration for the elastic stack that makes ingesting and displaying data work with as little user interaction as possible.

* link:index-templates.asciidoc[Elasticsearch Index Templates]
* Kibana Index Patterns
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"dependencies": {
"@babel/core": "^7.9.0",
"@babel/register": "^7.9.0",
"@elastic/apm-rum": "^4.6.0",
"@elastic/apm-rum": "^5.1.1",
"@elastic/charts": "18.3.0",
"@elastic/datemath": "5.0.3",
"@elastic/ems-client": "7.8.0",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-config-schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
export { ObjectType, TypeOf, Type };
export { ByteSizeValue } from './byte_size_value';
export { SchemaTypeError, ValidationError } from './errors';
export { isConfigSchema } from './typeguards';

function any(options?: TypeOptions<any>) {
return new AnyType(options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
* under the License.
*/

export { npSetup, npStart } from 'ui/new_platform';
export { PluginsStart } from 'ui/new_platform/new_platform';
export { isConfigSchema } from './is_config_schema';
56 changes: 56 additions & 0 deletions packages/kbn-config-schema/src/typeguards/is_config_schema.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.
*/

import { schema } from '..';
import { isConfigSchema } from './is_config_schema';

describe('isConfigSchema', () => {
it('returns true for every sub classes of `Type`', () => {
expect(isConfigSchema(schema.any())).toBe(true);
expect(isConfigSchema(schema.arrayOf(schema.string()))).toBe(true);
expect(isConfigSchema(schema.boolean())).toBe(true);
expect(isConfigSchema(schema.buffer())).toBe(true);
expect(isConfigSchema(schema.byteSize())).toBe(true);
expect(isConfigSchema(schema.duration())).toBe(true);
expect(isConfigSchema(schema.literal(''))).toBe(true);
expect(isConfigSchema(schema.mapOf(schema.string(), schema.number()))).toBe(true);
expect(isConfigSchema(schema.nullable(schema.string()))).toBe(true);
expect(isConfigSchema(schema.number())).toBe(true);
expect(isConfigSchema(schema.object({}))).toBe(true);
expect(isConfigSchema(schema.oneOf([schema.string()]))).toBe(true);
expect(isConfigSchema(schema.recordOf(schema.string(), schema.object({})))).toBe(true);
expect(isConfigSchema(schema.string())).toBe(true);
expect(isConfigSchema(schema.stream())).toBe(true);
});

it('returns false for every javascript data type', () => {
expect(isConfigSchema('foo')).toBe(false);
expect(isConfigSchema(42)).toBe(false);
expect(isConfigSchema(new Date())).toBe(false);
expect(isConfigSchema(null)).toBe(false);
expect(isConfigSchema(undefined)).toBe(false);
expect(isConfigSchema([1, 2, 3])).toBe(false);
expect(isConfigSchema({ foo: 'bar' })).toBe(false);
expect(isConfigSchema(function() {})).toBe(false);
});

it('returns true as long as `__isKbnConfigSchemaType` is true', () => {
expect(isConfigSchema({ __isKbnConfigSchemaType: true })).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
* under the License.
*/

require('jquery.flot');
require('jquery.flot.time');
require('jquery.flot.symbol');
require('jquery.flot.crosshair');
require('jquery.flot.selection');
require('jquery.flot.stack');
require('jquery.flot.axislabels');
import { Type } from '../types';

export function isConfigSchema(obj: any): obj is Type<any> {
return obj ? obj.__isKbnConfigSchemaType === true : false;
}
3 changes: 3 additions & 0 deletions packages/kbn-config-schema/src/types/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export abstract class Type<V> {
// sets the value to `null` while still keeping the type.
public readonly type: V = null! as V;

// used for the `isConfigSchema` typeguard
public readonly __isKbnConfigSchemaType = true;

/**
* Internal "schema" backed by Joi.
* @type {Schema}
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/http/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { Request, ResponseObject, ResponseToolkit } from 'hapi';
import Boom from 'boom';

import { Type } from '@kbn/config-schema';
import { isConfigSchema } from '@kbn/config-schema';
import { Logger } from '../../logging';
import { KibanaRequest } from './request';
import { KibanaResponseFactory, kibanaResponseFactory, IKibanaResponse } from './response';
Expand Down Expand Up @@ -139,7 +139,7 @@ function routeSchemasFromRouteConfig<P, Q, B>(

if (route.validate !== false) {
Object.entries(route.validate).forEach(([key, schema]) => {
if (!(schema instanceof Type || typeof schema === 'function')) {
if (!(isConfigSchema(schema) || typeof schema === 'function')) {
throw new Error(
`Expected a valid validation logic declared with '@kbn/config-schema' package or a RouteValidationFunction at key: [${key}].`
);
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/http/router/validator/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { ValidationError, Type, schema, ObjectType } from '@kbn/config-schema';
import { ValidationError, Type, schema, ObjectType, isConfigSchema } from '@kbn/config-schema';
import { Stream } from 'stream';
import { RouteValidationError } from './validator_error';

Expand Down Expand Up @@ -236,7 +236,7 @@ export class RouteValidator<P = {}, Q = {}, B = {}> {
data?: unknown,
namespace?: string
): RouteValidationResultType<typeof validationRule> {
if (validationRule instanceof Type) {
if (isConfigSchema(validationRule)) {
return validationRule.validate(data, {}, namespace);
} else if (typeof validationRule === 'function') {
return this.validateFunction(validationRule, data, namespace);
Expand Down
7 changes: 6 additions & 1 deletion src/core/server/legacy/legacy_service.test.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export const findLegacyPluginSpecsMock = jest.fn().mockImplementation((settings:
uiExports: {},
navLinks: [],
}));
jest.doMock('./plugins/find_legacy_plugin_specs.ts', () => ({
jest.doMock('./plugins/find_legacy_plugin_specs', () => ({
findLegacyPluginSpecs: findLegacyPluginSpecsMock,
}));

export const logLegacyThirdPartyPluginDeprecationWarningMock = jest.fn();
jest.doMock('./plugins/log_legacy_plugins_warning', () => ({
logLegacyThirdPartyPluginDeprecationWarning: logLegacyThirdPartyPluginDeprecationWarningMock,
}));
37 changes: 36 additions & 1 deletion src/core/server/legacy/legacy_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ jest.mock('../../../cli/cluster/cluster_manager');
jest.mock('./config/legacy_deprecation_adapters', () => ({
convertLegacyDeprecationProvider: (provider: any) => Promise.resolve(provider),
}));
import { findLegacyPluginSpecsMock } from './legacy_service.test.mocks';
import {
findLegacyPluginSpecsMock,
logLegacyThirdPartyPluginDeprecationWarningMock,
} from './legacy_service.test.mocks';

import { BehaviorSubject, throwError } from 'rxjs';

Expand Down Expand Up @@ -476,6 +479,38 @@ describe('#discoverPlugins()', () => {
expect(configService.addDeprecationProvider).toHaveBeenCalledWith('', 'providerA');
expect(configService.addDeprecationProvider).toHaveBeenCalledWith('', 'providerB');
});

it(`logs deprecations for legacy third party plugins`, async () => {
const pluginSpecs = [
{ getId: () => 'pluginA', getDeprecationsProvider: () => undefined },
{ getId: () => 'pluginB', getDeprecationsProvider: () => undefined },
];
findLegacyPluginSpecsMock.mockImplementation(
settings =>
Promise.resolve({
pluginSpecs,
pluginExtendedConfig: settings,
disabledPluginSpecs: [],
uiExports: {},
navLinks: [],
}) as any
);

const legacyService = new LegacyService({
coreId,
env,
logger,
configService: configService as any,
});

await legacyService.discoverPlugins();

expect(logLegacyThirdPartyPluginDeprecationWarningMock).toHaveBeenCalledTimes(1);
expect(logLegacyThirdPartyPluginDeprecationWarningMock).toHaveBeenCalledWith({
specs: pluginSpecs,
log: expect.any(Object),
});
});
});

test('Sets the server.uuid property on the legacy configuration', async () => {
Expand Down
7 changes: 6 additions & 1 deletion src/core/server/legacy/legacy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { DevConfig, DevConfigType, config as devConfig } from '../dev';
import { BasePathProxyServer, HttpConfig, HttpConfigType, config as httpConfig } from '../http';
import { Logger } from '../logging';
import { PathConfigType } from '../path';
import { findLegacyPluginSpecs } from './plugins';
import { findLegacyPluginSpecs, logLegacyThirdPartyPluginDeprecationWarning } from './plugins';
import { convertLegacyDeprecationProvider } from './config';
import {
ILegacyInternals,
Expand Down Expand Up @@ -133,6 +133,11 @@ export class LegacyService implements CoreService {
this.coreContext.env.packageInfo
);

logLegacyThirdPartyPluginDeprecationWarning({
specs: pluginSpecs,
log: this.log,
});

this.legacyPlugins = {
pluginSpecs,
disabledPluginSpecs,
Expand Down
1 change: 1 addition & 0 deletions src/core/server/legacy/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
*/

export { findLegacyPluginSpecs } from './find_legacy_plugin_specs';
export { logLegacyThirdPartyPluginDeprecationWarning } from './log_legacy_plugins_warning';
Loading

0 comments on commit ac44be3

Please sign in to comment.