mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Fleet] Fix preconfiguration inputs enablement (#126205)
This commit is contained in:
parent
324245c94c
commit
b1444ca4be
2 changed files with 7 additions and 10 deletions
|
@ -1704,8 +1704,8 @@ describe('Package policy service', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('when an input or stream is disabled on the original policy object', () => {
|
||||
it('remains disabled on the resulting policy object', () => {
|
||||
describe('when an input or stream is disabled by default in the package', () => {
|
||||
it('allow preconfiguration to enable it', () => {
|
||||
const basePackagePolicy: NewPackagePolicy = {
|
||||
name: 'base-package-policy',
|
||||
description: 'Base Package Policy',
|
||||
|
@ -1914,13 +1914,13 @@ describe('Package policy service', () => {
|
|||
expect(template2Inputs).toHaveLength(1);
|
||||
|
||||
const logsInput = template1Inputs?.find((input) => input.type === 'logs');
|
||||
expect(logsInput?.enabled).toBe(false);
|
||||
expect(logsInput?.enabled).toBe(true);
|
||||
|
||||
const logfileStream = logsInput?.streams.find(
|
||||
(stream) => stream.data_stream.type === 'logfile'
|
||||
);
|
||||
|
||||
expect(logfileStream?.enabled).toBe(false);
|
||||
expect(logfileStream?.enabled).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1323,14 +1323,11 @@ export function preconfigurePackageInputs(
|
|||
continue;
|
||||
}
|
||||
|
||||
// For flags like this, we only want to override the original value if it was set
|
||||
// as `undefined` in the original object. An explicit true/false value should be
|
||||
// persisted from the original object to the result after the override process is complete.
|
||||
if (originalInput.enabled === undefined && preconfiguredInput.enabled !== undefined) {
|
||||
if (preconfiguredInput.enabled !== undefined) {
|
||||
originalInput.enabled = preconfiguredInput.enabled;
|
||||
}
|
||||
|
||||
if (originalInput.keep_enabled === undefined && preconfiguredInput.keep_enabled !== undefined) {
|
||||
if (preconfiguredInput.keep_enabled !== undefined) {
|
||||
originalInput.keep_enabled = preconfiguredInput.keep_enabled;
|
||||
}
|
||||
|
||||
|
@ -1353,7 +1350,7 @@ export function preconfigurePackageInputs(
|
|||
continue;
|
||||
}
|
||||
|
||||
if (originalStream?.enabled === undefined) {
|
||||
if (stream.enabled !== undefined) {
|
||||
originalStream.enabled = stream.enabled;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue