-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fleet] Display package root requirements (#170478)
- Loading branch information
Showing
8 changed files
with
168 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
x-pack/plugins/fleet/common/services/package_helpers.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { isRootPrivilegesRequired } from './package_helpers'; | ||
|
||
describe('isRootPrivilegesRequired', () => { | ||
it('should return true if root privileges is required at root level', () => { | ||
const res = isRootPrivilegesRequired({ | ||
agent: { | ||
privileges: { | ||
root: true, | ||
}, | ||
}, | ||
} as any); | ||
expect(res).toBe(true); | ||
}); | ||
it('should return true if root privileges is required at datastreams', () => { | ||
const res = isRootPrivilegesRequired({ | ||
data_streams: [ | ||
{ | ||
agent: { | ||
privileges: { root: true }, | ||
}, | ||
}, | ||
], | ||
} as any); | ||
expect(res).toBe(true); | ||
}); | ||
|
||
it('should return false if root privileges is not required', () => { | ||
const res = isRootPrivilegesRequired({ | ||
data_streams: [], | ||
} as any); | ||
expect(res).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { PackageInfo } from '../types'; | ||
|
||
/** | ||
* Return true if a package need Elastic Agent to be run as root/administrator | ||
*/ | ||
export function isRootPrivilegesRequired(packageInfo: PackageInfo) { | ||
return ( | ||
packageInfo.agent?.privileges?.root || | ||
packageInfo.data_streams?.some((d) => d.agent?.privileges?.root) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...et/public/applications/integrations/sections/epm/screens/detail/overview/requirements.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import React, { memo } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiText, EuiDescriptionList, EuiToolTip } from '@elastic/eui'; | ||
|
||
export const Requirements: React.FC = memo(() => { | ||
return ( | ||
<EuiFlexGroup direction="column" gutterSize="s"> | ||
<EuiFlexItem> | ||
<EuiFlexGroup | ||
direction="row" | ||
alignItems="center" | ||
gutterSize="xs" | ||
justifyContent="spaceBetween" | ||
> | ||
<EuiFlexItem grow={false}> | ||
<EuiText> | ||
<h4> | ||
<FormattedMessage | ||
id="xpack.fleet.epm.requirementsTitle" | ||
defaultMessage="Requirements" | ||
/> | ||
</h4> | ||
</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
|
||
<EuiFlexItem> | ||
<EuiDescriptionList | ||
type="column" | ||
compressed | ||
listItems={[ | ||
{ | ||
title: i18n.translate('xpack.fleet.epm.requirements.permissionLabel', { | ||
defaultMessage: 'Permissions', | ||
}), | ||
description: ( | ||
<> | ||
<EuiToolTip | ||
content={i18n.translate( | ||
'xpack.fleet.epm.requirements.permissionRequireRootTooltip', | ||
{ | ||
defaultMessage: | ||
'Elastic agent needs to be run with root or administor privileges', | ||
} | ||
)} | ||
> | ||
<FormattedMessage | ||
id="xpack.fleet.epm.requirements.permissionRequireRootMessage" | ||
defaultMessage="root privileges" | ||
/> | ||
</EuiToolTip> | ||
</> | ||
), | ||
}, | ||
]} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
}); |