mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [[Fleet] Support input variable for integrations package (#202362)](https://github.com/elastic/kibana/pull/202362) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nicolas Chaulet","email":"nicolas.chaulet@elastic.co"},"sourceCommit":{"committedDate":"2024-12-02T13:12:42Z","message":"[Fleet] Support input variable for integrations package (#202362)","sha":"f21fdaf563d9cfcbed2adb61f07346f96045136a","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v9.0.0","backport:prev-minor"],"title":"[Fleet] Support input variable for integrations package","number":202362,"url":"https://github.com/elastic/kibana/pull/202362","mergeCommit":{"message":"[Fleet] Support input variable for integrations package (#202362)","sha":"f21fdaf563d9cfcbed2adb61f07346f96045136a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202362","number":202362,"mergeCommit":{"message":"[Fleet] Support input variable for integrations package (#202362)","sha":"f21fdaf563d9cfcbed2adb61f07346f96045136a"}}]}] BACKPORT--> Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
This commit is contained in:
parent
97e87595dd
commit
8b9dcb3241
2 changed files with 40 additions and 3 deletions
|
@ -469,6 +469,45 @@ describe('Fleet - packageToPackagePolicy', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('returns package policy with inputs variables', () => {
|
||||
const mockPackageWithPolicyTemplates = {
|
||||
...mockPackage,
|
||||
policy_templates: [
|
||||
{ inputs: [{ type: 'foo' }] },
|
||||
{ inputs: [{ type: 'bar', vars: [{ default: 'bar-var-value', name: 'var-name' }] }] },
|
||||
],
|
||||
} as unknown as PackageInfo;
|
||||
|
||||
expect(
|
||||
packageToPackagePolicy(
|
||||
mockPackageWithPolicyTemplates,
|
||||
'policy-id-1',
|
||||
'default',
|
||||
'pkgPolicy-1'
|
||||
)
|
||||
).toEqual({
|
||||
policy_id: 'policy-id-1',
|
||||
policy_ids: ['policy-id-1'],
|
||||
namespace: 'default',
|
||||
enabled: true,
|
||||
inputs: [
|
||||
{ type: 'foo', enabled: true, streams: [] },
|
||||
{
|
||||
type: 'bar',
|
||||
enabled: true,
|
||||
streams: [],
|
||||
vars: { 'var-name': { value: 'bar-var-value' } },
|
||||
},
|
||||
],
|
||||
name: 'pkgPolicy-1',
|
||||
package: {
|
||||
name: 'mock-package',
|
||||
title: 'Mock package',
|
||||
version: '0.0.0',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('returns package policy with multiple policy templates (aka has integrations', () => {
|
||||
expect(
|
||||
packageToPackagePolicy(
|
||||
|
|
|
@ -147,9 +147,7 @@ export const packageToPackagePolicyInputs = (
|
|||
return stream;
|
||||
});
|
||||
|
||||
// If non-integration package, collect input-level vars, otherwise skip them,
|
||||
// we do not support input-level vars for packages with integrations yet)
|
||||
if (packageInput.vars?.length && !hasIntegrations) {
|
||||
if (packageInput.vars?.length) {
|
||||
varsForInput = packageInput.vars.reduce(varsReducer, {});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue