Skip to content

Commit

Permalink
[Fleet] Display package root requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Nov 2, 2023
1 parent 876a762 commit 03c7255
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
7 changes: 7 additions & 0 deletions x-pack/plugins/fleet/common/types/models/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ export enum RegistryDataStreamKeys {
dataset_is_prefix = 'dataset_is_prefix',
routing_rules = 'routing_rules',
lifecycle = 'lifecycle',
agent = 'agent',
}

export interface RegistryDataStream {
Expand All @@ -355,6 +356,12 @@ export interface RegistryDataStream {
[RegistryDataStreamKeys.dataset_is_prefix]?: boolean;
[RegistryDataStreamKeys.routing_rules]?: RegistryDataStreamRoutingRules[];
[RegistryDataStreamKeys.lifecycle]?: RegistryDataStreamLifecycle;
[RegistryDataStreamKeys.lifecycle]?: RegistryDataStreamLifecycle;
[RegistryDataStreamKeys.agent]?: RegistryAgent;
}

export interface RegistryAgent {
privileges?: { root?: boolean };
}

export interface RegistryElasticsearch {
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/fleet/common/types/models/package_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export interface PackageSpecManifest {
RegistryElasticsearch,
'index_template.settings' | 'index_template.mappings' | 'index_template.data_stream'
>;
agent?: {
privileges?: { root?: boolean };
};
asset_tags?: PackageSpecTags[];
}
export interface PackageSpecTags {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type { PackageInfo, RegistryPolicyTemplate } from '../../../../../types';
import { Screenshots } from './screenshots';
import { Readme } from './readme';
import { Details } from './details';
import { Requirements } from './requirements';

interface Props {
packageInfo: PackageInfo;
Expand Down Expand Up @@ -277,6 +278,10 @@ export const OverviewPage: React.FC<Props> = memo(
];
}, [h1, navItems]);

const requireAgentRootPrivileges =
packageInfo.agent?.privileges?.root ||
packageInfo.data_streams?.some((d) => d.agent?.privileges?.root); // TODO move to an util function that can be tested

return (
<EuiFlexGroup alignItems="flexStart" data-test-subj="epm.OverviewPage">
<SideBar grow={2}>
Expand Down Expand Up @@ -309,6 +314,11 @@ export const OverviewPage: React.FC<Props> = memo(
</EuiFlexItem>
<EuiFlexItem grow={3}>
<EuiFlexGroup direction="column" gutterSize="l" alignItems="flexStart">
{requireAgentRootPrivileges ? (
<EuiFlexItem>
<Requirements />
</EuiFlexItem>
) : null}
{screenshots.length ? (
<EuiFlexItem>
<Screenshots
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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 } 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: (
<>
<FormattedMessage
id="xpack.fleet.epm.requirements.permissionRequireRootMessage"
defaultMessage="root privileges"
/>
</>
),
},
]}
/>
</EuiFlexItem>
</EuiFlexGroup>
);
});

0 comments on commit 03c7255

Please sign in to comment.