Skip to content

Commit

Permalink
[Fleet] Add the @Custom pipeline only to the main datastream ingest p…
Browse files Browse the repository at this point in the history
…ipelines
  • Loading branch information
nchaulet committed Oct 27, 2022
1 parent 7bc63e0 commit dbd4666
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ describe('Install pipeline tests', () => {
await res.install(esClient, logger);

expect(esClient.ingest.putPipeline).toBeCalled();

// It should add the @custom pipeline for the main pipeline
const pipelinesWithCustomProcessor = esClient.ingest.putPipeline.mock.calls.filter((call) =>
// @ts-ignore-error
call[0]?.body.includes('@custom')
);

expect(pipelinesWithCustomProcessor).toHaveLength(1);
});

it('should work with datastream with ingest pipelines define in the package', async () => {
Expand Down Expand Up @@ -73,6 +81,14 @@ describe('Install pipeline tests', () => {
await res.install(esClient, logger);

expect(esClient.ingest.putPipeline).toBeCalledTimes(2);

// It should add the @custom pipeline only for the main pipeline
const pipelinesWithCustomProcessor = esClient.ingest.putPipeline.mock.calls.filter((call) =>
// @ts-ignore-error
call[0]?.body.includes('@custom')
);

expect(pipelinesWithCustomProcessor).toHaveLength(1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ export async function installAllPipelines({
let datastreamPipelineCreated = false;
pipelinePaths.forEach((path) => {
const { name, extension } = getNameAndExtension(path);
if (name === dataStream?.ingest_pipeline) {
const isMainPipeline = name === dataStream?.ingest_pipeline;
if (isMainPipeline) {
datastreamPipelineCreated = true;
}
const nameForInstallation = getPipelineNameForInstallation({
Expand All @@ -168,9 +169,8 @@ export async function installAllPipelines({
const content = getAsset(path).toString('utf-8');
pipelinesInfos.push({
nameForInstallation,
customIngestPipelineNameForInstallation: dataStream
? getCustomPipelineNameForDatastream(dataStream)
: undefined,
customIngestPipelineNameForInstallation:
dataStream && isMainPipeline ? getCustomPipelineNameForDatastream(dataStream) : undefined,
content,
extension,
});
Expand Down

0 comments on commit dbd4666

Please sign in to comment.