Skip to content

Commit 2afda68

Browse files
Merge branch 'master' into implement/asset-size-metrics
2 parents 88f9229 + 513d0e0 commit 2afda68

98 files changed

Lines changed: 2379 additions & 378 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/api/saved-objects/bulk_get.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ experimental[] Retrieve multiple {kib} saved objects by ID.
2929
(Required, string) ID of the retrieved object. The ID includes the {kib} unique identifier or a custom identifier.
3030

3131
`fields`::
32-
(Optional, array) The fields returned in the object response.
32+
(Optional, array) The fields to return in the `attributes` key of the object response.
3333

3434
[[saved-objects-api-bulk-get-response-body]]
3535
==== Response body

docs/api/saved-objects/find.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ experimental[] Retrieve a paginated set of {kib} saved objects by various condit
4141
(Optional, array|string) The fields to perform the `simple_query_string` parsed query against.
4242

4343
`fields`::
44-
(Optional, array|string) The fields to return in the response.
44+
(Optional, array|string) The fields to return in the `attributes` key of the response.
4545

4646
`sort_field`::
4747
(Optional, string) The field that sorts the response.

src/plugins/vis_type_vega/public/vega_visualization.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ jest.mock('./lib/vega', () => ({
5252
vegaLite: jest.requireActual('vega-lite'),
5353
}));
5454

55-
describe('VegaVisualizations', () => {
55+
// FLAKY: https://github.com/elastic/kibana/issues/71713
56+
describe.skip('VegaVisualizations', () => {
5657
let domNode;
5758
let VegaVisualization;
5859
let vis;

x-pack/plugins/alerts/server/alerts_client.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
*/
66

77
import Boom from 'boom';
8-
import { omit, isEqual, map } from 'lodash';
8+
import { omit, isEqual, map, truncate } from 'lodash';
99
import { i18n } from '@kbn/i18n';
1010
import {
1111
Logger,
1212
SavedObjectsClientContract,
1313
SavedObjectReference,
1414
SavedObject,
1515
} from 'src/core/server';
16-
import _ from 'lodash';
1716
import { ActionsClient } from '../../actions/server';
1817
import {
1918
Alert,
@@ -713,6 +712,6 @@ export class AlertsClient {
713712
}
714713

715714
private generateAPIKeyName(alertTypeId: string, alertName: string) {
716-
return _.truncate(`Alerting: ${alertTypeId}/${alertName}`, { length: 256 });
715+
return truncate(`Alerting: ${alertTypeId}/${alertName}`, { length: 256 });
717716
}
718717
}

x-pack/plugins/ingest_manager/server/services/epm/fields/field.test.ts

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,181 @@ describe('processFields', () => {
269269
expect(processFields(nested)).toEqual(nestedExpanded);
270270
});
271271

272+
test('correctly handles properties of nested and object type fields together', () => {
273+
const fields = [
274+
{
275+
name: 'a',
276+
type: 'object',
277+
},
278+
{
279+
name: 'a.b',
280+
type: 'nested',
281+
},
282+
{
283+
name: 'a.b.c',
284+
type: 'boolean',
285+
},
286+
{
287+
name: 'a.b.d',
288+
type: 'keyword',
289+
},
290+
];
291+
292+
const fieldsExpanded = [
293+
{
294+
name: 'a',
295+
type: 'group',
296+
fields: [
297+
{
298+
name: 'b',
299+
type: 'group-nested',
300+
fields: [
301+
{
302+
name: 'c',
303+
type: 'boolean',
304+
},
305+
{
306+
name: 'd',
307+
type: 'keyword',
308+
},
309+
],
310+
},
311+
],
312+
},
313+
];
314+
expect(processFields(fields)).toEqual(fieldsExpanded);
315+
});
316+
317+
test('correctly handles properties of nested and object type fields in large depth', () => {
318+
const fields = [
319+
{
320+
name: 'a.h-object',
321+
type: 'object',
322+
dynamic: false,
323+
},
324+
{
325+
name: 'a.b-nested.c-nested',
326+
type: 'nested',
327+
},
328+
{
329+
name: 'a.b-nested',
330+
type: 'nested',
331+
},
332+
{
333+
name: 'a',
334+
type: 'object',
335+
},
336+
{
337+
name: 'a.b-nested.d',
338+
type: 'keyword',
339+
},
340+
{
341+
name: 'a.b-nested.c-nested.e',
342+
type: 'boolean',
343+
dynamic: true,
344+
},
345+
{
346+
name: 'a.b-nested.c-nested.f-object',
347+
type: 'object',
348+
},
349+
{
350+
name: 'a.b-nested.c-nested.f-object.g',
351+
type: 'keyword',
352+
},
353+
];
354+
355+
const fieldsExpanded = [
356+
{
357+
name: 'a',
358+
type: 'group',
359+
fields: [
360+
{
361+
name: 'h-object',
362+
type: 'object',
363+
dynamic: false,
364+
},
365+
{
366+
name: 'b-nested',
367+
type: 'group-nested',
368+
fields: [
369+
{
370+
name: 'c-nested',
371+
type: 'group-nested',
372+
fields: [
373+
{
374+
name: 'e',
375+
type: 'boolean',
376+
dynamic: true,
377+
},
378+
{
379+
name: 'f-object',
380+
type: 'group',
381+
fields: [
382+
{
383+
name: 'g',
384+
type: 'keyword',
385+
},
386+
],
387+
},
388+
],
389+
},
390+
{
391+
name: 'd',
392+
type: 'keyword',
393+
},
394+
],
395+
},
396+
],
397+
},
398+
];
399+
expect(processFields(fields)).toEqual(fieldsExpanded);
400+
});
401+
402+
test('correctly handles properties of nested and object type fields together in different order', () => {
403+
const fields = [
404+
{
405+
name: 'a.b.c',
406+
type: 'boolean',
407+
},
408+
{
409+
name: 'a.b',
410+
type: 'nested',
411+
},
412+
{
413+
name: 'a',
414+
type: 'object',
415+
},
416+
{
417+
name: 'a.b.d',
418+
type: 'keyword',
419+
},
420+
];
421+
422+
const fieldsExpanded = [
423+
{
424+
name: 'a',
425+
type: 'group',
426+
fields: [
427+
{
428+
name: 'b',
429+
type: 'group-nested',
430+
fields: [
431+
{
432+
name: 'c',
433+
type: 'boolean',
434+
},
435+
{
436+
name: 'd',
437+
type: 'keyword',
438+
},
439+
],
440+
},
441+
],
442+
},
443+
];
444+
expect(processFields(fields)).toEqual(fieldsExpanded);
445+
});
446+
272447
test('correctly handles properties of nested type where nested top level comes second', () => {
273448
const nested = [
274449
{

x-pack/plugins/ingest_manager/server/services/epm/fields/field.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,21 @@ function dedupFields(fields: Fields): Fields {
126126
if (
127127
// only merge if found is a group and field is object, nested, or group.
128128
// Or if found is object, or nested, and field is a group.
129-
// This is to avoid merging two objects, or nested, or object with a nested.
129+
// This is to avoid merging two objects, or two nested, or object with a nested.
130+
131+
// we do not need to check for group-nested in this part because `field` will never have group-nested
132+
// it can only exist on `found`
130133
(found.type === 'group' &&
131134
(field.type === 'object' || field.type === 'nested' || field.type === 'group')) ||
132-
((found.type === 'object' || found.type === 'nested') && field.type === 'group')
135+
// as part of the loop we will be marking found.type as group-nested so found could be group-nested if it was
136+
// already processed. If we had an explicit definition of nested, and it showed up before a descendant field:
137+
// - name: a
138+
// type: nested
139+
// - name: a.b
140+
// type: keyword
141+
// then found.type will be nested and not group-nested because it won't have any fields yet until a.b is processed
142+
((found.type === 'object' || found.type === 'nested' || found.type === 'group-nested') &&
143+
field.type === 'group')
133144
) {
134145
// if the new field has properties let's dedup and concat them with the already existing found variable in
135146
// the array
@@ -148,10 +159,10 @@ function dedupFields(fields: Fields): Fields {
148159
// supposed to be `nested` for when the template is actually generated
149160
if (found.type === 'nested' || field.type === 'nested') {
150161
found.type = 'group-nested';
151-
} else {
152-
// found was either `group` already or `object` so just set it to `group`
162+
} else if (found.type === 'object') {
153163
found.type = 'group';
154164
}
165+
// found.type could be group-nested or group, in those cases just leave it
155166
}
156167
// we need to merge in other properties (like `dynamic`) that might exist
157168
Object.assign(found, importantFieldProps);

x-pack/plugins/ingest_manager/server/services/epm/registry/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { ArchiveEntry, untarBuffer } from './extract';
2121
import { fetchUrl, getResponse, getResponseStream } from './requests';
2222
import { streamToBuffer } from './streams';
2323
import { getRegistryUrl } from './registry_url';
24+
import { appContextService } from '../..';
2425

2526
export { ArchiveEntry } from './extract';
2627

@@ -47,6 +48,10 @@ export async function fetchList(params?: SearchParams): Promise<RegistrySearchRe
4748
url.searchParams.set('experimental', params.experimental.toString());
4849
}
4950
}
51+
const kibanaVersion = appContextService.getKibanaVersion().split('-')[0]; // may be 8.0.0-SNAPSHOT
52+
if (kibanaVersion) {
53+
url.searchParams.set('kibana.version', kibanaVersion);
54+
}
5055

5156
return fetchUrl(url.toString()).then(JSON.parse);
5257
}
@@ -56,6 +61,10 @@ export async function fetchFindLatestPackage(packageName: string): Promise<Regis
5661
const url = new URL(
5762
`${registryUrl}/search?package=${packageName}&internal=true&experimental=true`
5863
);
64+
const kibanaVersion = appContextService.getKibanaVersion().split('-')[0]; // may be 8.0.0-SNAPSHOT
65+
if (kibanaVersion) {
66+
url.searchParams.set('kibana.version', kibanaVersion);
67+
}
5968
const res = await fetchUrl(url.toString());
6069
const searchResults = JSON.parse(res);
6170
if (searchResults.length) {

0 commit comments

Comments
 (0)