[Ingest Manager] Fix agent stream to support optionnal yaml root values (#68272)
* [Ingest Manager] Fix agent stream to support optionnal yaml root values * Update x-pack/plugins/ingest_manager/server/services/epm/agent/agent.test.ts Co-authored-by: Jen Huang <its.jenetic@gmail.com> Co-authored-by: Jen Huang <its.jenetic@gmail.com>
This commit is contained in:
parent
8fe1eb1f78
commit
f7739b5db6
2 changed files with 22 additions and 1 deletions
|
@ -83,4 +83,22 @@ foo: bar
|
|||
custom: { foo: 'bar' },
|
||||
});
|
||||
});
|
||||
|
||||
it('should support optional yaml values at root level', () => {
|
||||
const streamTemplate = `
|
||||
input: logs
|
||||
{{custom}}
|
||||
`;
|
||||
const vars = {
|
||||
custom: {
|
||||
type: 'yaml',
|
||||
value: null,
|
||||
},
|
||||
};
|
||||
|
||||
const output = createStream(vars, streamTemplate);
|
||||
expect(output).toEqual({
|
||||
input: 'logs',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -94,7 +94,10 @@ function replaceRootLevelYamlVariables(yamlVariables: { [k: string]: any }, yaml
|
|||
|
||||
let patchedTemplate = yamlTemplate;
|
||||
Object.entries(yamlVariables).forEach(([key, val]) => {
|
||||
patchedTemplate = patchedTemplate.replace(new RegExp(`^"${key}"`, 'gm'), safeDump(val));
|
||||
patchedTemplate = patchedTemplate.replace(
|
||||
new RegExp(`^"${key}"`, 'gm'),
|
||||
val ? safeDump(val) : ''
|
||||
);
|
||||
});
|
||||
|
||||
return patchedTemplate;
|
||||
|
|
Loading…
Reference in a new issue