From 0ee92df29b88b882557b9b74e1807642484cccd7 Mon Sep 17 00:00:00 2001 From: Hanna Tamoudi Date: Wed, 25 Sep 2024 14:47:16 +0200 Subject: [PATCH] [Automatic Import] move base-fields into fields folder (#193960) --- .../server/integration_builder/fields.test.ts | 10 ++++++++-- .../server/integration_builder/fields.ts | 13 +++++++------ 2 files changed, 15 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 4b85cfe7324d5..a657f699cfff9 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 @@ -46,7 +46,10 @@ describe('createFieldMapping', () => { type: keyword `; - expect(createSync).toHaveBeenCalledWith(`${dataStreamPath}/base-fields.yml`, mockedTemplate); + expect(createSync).toHaveBeenCalledWith( + `${dataStreamPath}/fields/base-fields.yml`, + mockedTemplate + ); expect(createSync).toHaveBeenCalledWith(`${dataStreamPath}/fields/fields.yml`, expectedFields); }); @@ -56,7 +59,10 @@ describe('createFieldMapping', () => { const expectedFields = `[] `; - expect(createSync).toHaveBeenCalledWith(`${dataStreamPath}/base-fields.yml`, mockedTemplate); + expect(createSync).toHaveBeenCalledWith( + `${dataStreamPath}/fields/base-fields.yml`, + mockedTemplate + ); expect(createSync).toHaveBeenCalledWith(`${dataStreamPath}/fields/fields.yml`, expectedFields); }); }); 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); }