Skip to content

Commit

Permalink
[Automatic Import] move base-fields into fields folder (elastic#193960)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0ee92df)

# Conflicts:
#	x-pack/plugins/integration_assistant/server/integration_builder/fields.test.ts
  • Loading branch information
haetamoudi committed Sep 25, 2024
1 parent 24bec01 commit bba5505
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,10 @@ describe('createFieldMapping', () => {
`;

expect(Utils.createSync).toHaveBeenCalledWith(
`${dataStreamPath}/base-fields.yml`,
`${dataStreamPath}/fields/base-fields.yml`,
mockedTemplate
);
expect(Utils.createSync).toHaveBeenCalledWith(
`${dataStreamPath}/fields/fields.yml`,
expectedFields
);
expect(Utils.createSync).toHaveBeenCalledWith(`${dataStreamPath}/fields/fields.yml`, expectedFields);
});

it('Should create fields files even if docs value is empty', async () => {
Expand All @@ -63,12 +60,9 @@ describe('createFieldMapping', () => {
`;

expect(Utils.createSync).toHaveBeenCalledWith(
`${dataStreamPath}/base-fields.yml`,
`${dataStreamPath}/fields/base-fields.yml`,
mockedTemplate
);
expect(Utils.createSync).toHaveBeenCalledWith(
`${dataStreamPath}/fields/fields.yml`,
expectedFields
);
expect(Utils.createSync).toHaveBeenCalledWith(`${dataStreamPath}/fields/fields.yml`, expectedFields);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}

0 comments on commit bba5505

Please sign in to comment.