From 12cb67db5eb81bd9446e42612b3e4382256b434f Mon Sep 17 00:00:00 2001 From: Hanna Tamoudi Date: Thu, 26 Sep 2024 09:46:19 +0200 Subject: [PATCH] [8.15] [Automatic Import] move base-fields into fields folder (#193960) (#194025) # Backport This will backport the following commits from `main` to `8.15`: - [[Automatic Import] move base-fields into fields folder (#193960)](https://github.com/elastic/kibana/pull/193960) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) --- .../server/integration_builder/fields.test.ts | 4 ++-- .../server/integration_builder/fields.ts | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/integration_assistant/server/integration_builder/fields.test.ts b/x-pack/plugins/integration_assistant/server/integration_builder/fields.test.ts index 9bd134b21b62e..dc37fef76161f 100644 --- a/x-pack/plugins/integration_assistant/server/integration_builder/fields.test.ts +++ b/x-pack/plugins/integration_assistant/server/integration_builder/fields.test.ts @@ -47,7 +47,7 @@ describe('createFieldMapping', () => { `; expect(Utils.createSync).toHaveBeenCalledWith( - `${dataStreamPath}/base-fields.yml`, + `${dataStreamPath}/fields/base-fields.yml`, mockedTemplate ); expect(Utils.createSync).toHaveBeenCalledWith( @@ -63,7 +63,7 @@ describe('createFieldMapping', () => { `; expect(Utils.createSync).toHaveBeenCalledWith( - `${dataStreamPath}/base-fields.yml`, + `${dataStreamPath}/fields/base-fields.yml`, mockedTemplate ); expect(Utils.createSync).toHaveBeenCalledWith( diff --git a/x-pack/plugins/integration_assistant/server/integration_builder/fields.ts b/x-pack/plugins/integration_assistant/server/integration_builder/fields.ts index c95a15cbe871d..79977ef2f3927 100644 --- a/x-pack/plugins/integration_assistant/server/integration_builder/fields.ts +++ b/x-pack/plugins/integration_assistant/server/integration_builder/fields.ts @@ -15,12 +15,13 @@ export function createFieldMapping( specificDataStreamDir: string, docs: object[] ): void { - createBaseFields(specificDataStreamDir, packageName, dataStreamName); - createCustomFields(specificDataStreamDir, docs); + const dataStreamFieldsDir = `${specificDataStreamDir}/fields`; + createBaseFields(dataStreamFieldsDir, packageName, dataStreamName); + createCustomFields(dataStreamFieldsDir, docs); } function createBaseFields( - specificDataStreamDir: string, + dataStreamFieldsDir: string, packageName: string, dataStreamName: string ): void { @@ -30,11 +31,11 @@ function createBaseFields( dataset: datasetName, }); - createSync(`${specificDataStreamDir}/base-fields.yml`, baseFields); + createSync(`${dataStreamFieldsDir}/base-fields.yml`, baseFields); } -function createCustomFields(specificDataStreamDir: string, pipelineResults: object[]): void { +function createCustomFields(dataStreamFieldsDir: string, pipelineResults: object[]): void { const mergedResults = mergeSamples(pipelineResults); const fieldKeys = generateFields(mergedResults); - createSync(`${specificDataStreamDir}/fields/fields.yml`, fieldKeys); + createSync(`${dataStreamFieldsDir}/fields.yml`, fieldKeys); }