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
  • Loading branch information
haetamoudi authored Sep 25, 2024
1 parent 387afb7 commit 0ee92df
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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);
});
});
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 0ee92df

Please sign in to comment.