Skip to content

Commit

Permalink
Don't return empty streams in agent yaml when there aren't any
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang committed Nov 24, 2020
1 parent f0a9c97 commit 493e54a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ describe('Fleet - storedPackagePoliciesToAgentInputs', () => {
},
},
inputVar: 'input-value',
streams: [],
},
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,24 @@ export const storedPackagePoliciesToAgentInputs = (
return acc;
}, {} as { [k: string]: any }),
...(input.compiled_input || {}),
streams: input.streams
.filter((stream) => stream.enabled)
.map((stream) => {
const fullStream: FullAgentPolicyInputStream = {
id: stream.id,
data_stream: stream.data_stream,
...stream.compiled_stream,
...Object.entries(stream.config || {}).reduce((acc, [key, { value }]) => {
acc[key] = value;
return acc;
}, {} as { [k: string]: any }),
};
return fullStream;
}),
...(input.streams.length
? {
streams: input.streams
.filter((stream) => stream.enabled)
.map((stream) => {
const fullStream: FullAgentPolicyInputStream = {
id: stream.id,
data_stream: stream.data_stream,
...stream.compiled_stream,
...Object.entries(stream.config || {}).reduce((acc, [key, { value }]) => {
acc[key] = value;
return acc;
}, {} as { [k: string]: any }),
};
return fullStream;
}),
}
: {}),
};

if (packagePolicy.package) {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/common/types/models/agent_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface FullAgentPolicyInput {
package?: Pick<PackagePolicyPackage, 'name' | 'version'>;
[key: string]: unknown;
};
streams: FullAgentPolicyInputStream[];
streams?: FullAgentPolicyInputStream[];
[key: string]: any;
}

Expand Down

0 comments on commit 493e54a

Please sign in to comment.