Skip to content

Commit

Permalink
[8.15] [Automatic Import] move base-fields into fields folder (#193960)…
Browse files Browse the repository at this point in the history
… (#194025)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Automatic Import] move base-fields into fields folder
(#193960)](#193960)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Hanna
Tamoudi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-25T12:47:16Z","message":"[Automatic
Import] move base-fields into fields folder
(#193960)","sha":"0ee92df29b88b882557b9b74e1807642484cccd7","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","v9.0.0","backport:prev-major","Team:Security-Scalability","Feature:AutomaticImport"],"number":193960,"url":"https://github.com/elastic/kibana/pull/193960","mergeCommit":{"message":"[Automatic
Import] move base-fields into fields folder
(#193960)","sha":"0ee92df29b88b882557b9b74e1807642484cccd7"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193960","number":193960,"mergeCommit":{"message":"[Automatic
Import] move base-fields into fields folder
(#193960)","sha":"0ee92df29b88b882557b9b74e1807642484cccd7"}}]}]
BACKPORT-->
  • Loading branch information
haetamoudi authored Sep 26, 2024
1 parent b555633 commit 12cb67d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('createFieldMapping', () => {
`;

expect(Utils.createSync).toHaveBeenCalledWith(
`${dataStreamPath}/base-fields.yml`,
`${dataStreamPath}/fields/base-fields.yml`,
mockedTemplate
);
expect(Utils.createSync).toHaveBeenCalledWith(
Expand All @@ -63,7 +63,7 @@ describe('createFieldMapping', () => {
`;

expect(Utils.createSync).toHaveBeenCalledWith(
`${dataStreamPath}/base-fields.yml`,
`${dataStreamPath}/fields/base-fields.yml`,
mockedTemplate
);
expect(Utils.createSync).toHaveBeenCalledWith(
Expand Down
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 12cb67d

Please sign in to comment.