wizard/oscap: kernel and services customizations
This commit ports the work done on 40b1d4de to the V1 wizard.
This commit is contained in:
parent
60842057f8
commit
f83fd51468
6 changed files with 131 additions and 87 deletions
|
|
@ -97,6 +97,23 @@ const onSave = (values) => {
|
|||
customizations.openscap = {
|
||||
profile_id: values['oscap-profile'],
|
||||
};
|
||||
if (values['kernel']) {
|
||||
customizations.kernel = values['kernel'];
|
||||
}
|
||||
if (
|
||||
(Array.isArray(values['enabledServices']) &&
|
||||
values['enabledServices'].length > 0) ||
|
||||
(Array.isArray(values['disabledServices']) &&
|
||||
values['disabledServices'].length > 0)
|
||||
) {
|
||||
customizations.services = {};
|
||||
if (values['enabledServices'].length > 0) {
|
||||
customizations.services.enabled = values['enabledServices'];
|
||||
}
|
||||
if (values['disabledServices'].length > 0) {
|
||||
customizations.services.disabled = values['disabledServices'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const requests = [];
|
||||
|
|
@ -515,6 +532,11 @@ const requestToState = (composeRequest, isProd, enableOscap) => {
|
|||
if (enableOscap) {
|
||||
formState['oscap-profile'] =
|
||||
composeRequest?.customizations?.openscap?.profile_id;
|
||||
formState['kernel'] = composeRequest?.customizations?.kernel;
|
||||
formState['enabledServices'] =
|
||||
composeRequest?.customizations?.services?.enabled;
|
||||
formState['disabledServices'] =
|
||||
composeRequest?.customizations?.services?.disabled;
|
||||
}
|
||||
|
||||
return formState;
|
||||
|
|
|
|||
|
|
@ -87,6 +87,15 @@ const ProfileSelector = ({ input }: ProfileSelectorProps) => {
|
|||
) {
|
||||
setProfileName(data.openscap.profile_name);
|
||||
}
|
||||
if (data?.kernel) {
|
||||
change('kernel', data.kernel);
|
||||
}
|
||||
if (data?.services?.enabled) {
|
||||
change('enabledServices', data.services.enabled);
|
||||
}
|
||||
if (data?.services?.disabled) {
|
||||
change('disabledServices', data.services.disabled);
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
const handleToggle = () => {
|
||||
|
|
@ -99,6 +108,9 @@ const ProfileSelector = ({ input }: ProfileSelectorProps) => {
|
|||
const handleClear = () => {
|
||||
setProfile(undefined);
|
||||
change(input.name, undefined);
|
||||
change('kernel', undefined);
|
||||
change('disabledServices', undefined);
|
||||
change('enabledServices', undefined);
|
||||
// @ts-ignore
|
||||
setProfileName(undefined);
|
||||
reinitDependingSteps(change);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ import {
|
|||
TextListItem,
|
||||
TextListItemVariants,
|
||||
TextListVariants,
|
||||
CodeBlock,
|
||||
CodeBlockCode,
|
||||
Alert,
|
||||
} from '@patternfly/react-core';
|
||||
|
||||
import { RELEASES } from '../../../constants';
|
||||
|
|
@ -29,46 +32,95 @@ const OscapProfileInformation = (): JSX.Element => {
|
|||
}
|
||||
);
|
||||
|
||||
const enabledServicesDisplayString =
|
||||
oscapProfileInfo?.services?.enabled?.join(' ');
|
||||
const disableServicesDisplayString =
|
||||
oscapProfileInfo?.services?.disabled?.join(' ');
|
||||
|
||||
return (
|
||||
<>
|
||||
{isFetchingOscapProfileInfo && <Spinner size="lg" />}
|
||||
{isSuccessOscapProfileInfo && (
|
||||
<TextContent>
|
||||
<br />
|
||||
<TextList component={TextListVariants.dl}>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-u-min-width"
|
||||
>
|
||||
Profile description:
|
||||
</TextListItem>
|
||||
<TextListItem component={TextListItemVariants.dd}>
|
||||
{oscapProfileInfo.openscap?.profile_description}
|
||||
</TextListItem>
|
||||
</TextList>
|
||||
<TextList component={TextListVariants.dl}>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-u-min-width"
|
||||
>
|
||||
Operating system:
|
||||
</TextListItem>
|
||||
<TextListItem component={TextListItemVariants.dd}>
|
||||
{RELEASES.get(getState()?.values?.['release'])}
|
||||
</TextListItem>
|
||||
</TextList>
|
||||
<TextList component={TextListVariants.dl}>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-u-min-width"
|
||||
>
|
||||
Reference ID:
|
||||
</TextListItem>
|
||||
<TextListItem component={TextListItemVariants.dd}>
|
||||
{oscapProfileInfo.openscap?.profile_id}
|
||||
</TextListItem>
|
||||
</TextList>
|
||||
</TextContent>
|
||||
<>
|
||||
<TextContent>
|
||||
<br />
|
||||
<TextList component={TextListVariants.dl}>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-u-min-width"
|
||||
>
|
||||
Profile description:
|
||||
</TextListItem>
|
||||
<TextListItem component={TextListItemVariants.dd}>
|
||||
{oscapProfileInfo.openscap?.profile_description}
|
||||
</TextListItem>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-u-min-width"
|
||||
>
|
||||
Operating system:
|
||||
</TextListItem>
|
||||
<TextListItem component={TextListItemVariants.dd}>
|
||||
{RELEASES.get(getState()?.values?.['release'])}
|
||||
</TextListItem>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-u-min-width"
|
||||
>
|
||||
Reference ID:
|
||||
</TextListItem>
|
||||
<TextListItem component={TextListItemVariants.dd}>
|
||||
{oscapProfileInfo.openscap?.profile_id}
|
||||
</TextListItem>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-u-min-width"
|
||||
>
|
||||
Kernel arguments:
|
||||
</TextListItem>
|
||||
<TextListItem component={TextListItemVariants.dd}>
|
||||
<CodeBlock>
|
||||
<CodeBlockCode>
|
||||
{oscapProfileInfo?.kernel?.append}
|
||||
</CodeBlockCode>
|
||||
</CodeBlock>
|
||||
</TextListItem>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-u-min-width"
|
||||
>
|
||||
Disabled services:
|
||||
</TextListItem>
|
||||
<TextListItem component={TextListItemVariants.dd}>
|
||||
<CodeBlock>
|
||||
<CodeBlockCode>{disableServicesDisplayString}</CodeBlockCode>
|
||||
</CodeBlock>
|
||||
</TextListItem>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-u-min-width"
|
||||
>
|
||||
Enabled services:
|
||||
</TextListItem>
|
||||
<TextListItem component={TextListItemVariants.dd}>
|
||||
<CodeBlock>
|
||||
<CodeBlockCode>{enabledServicesDisplayString}</CodeBlockCode>
|
||||
</CodeBlock>
|
||||
</TextListItem>
|
||||
</TextList>
|
||||
</TextContent>
|
||||
|
||||
<Alert
|
||||
variant="info"
|
||||
isInline
|
||||
isPlain
|
||||
title="Additional customizations"
|
||||
>
|
||||
Selecting an OpenSCAP profile will cause the appropriate packages,
|
||||
file system configuration, kernel arguments, and services to be
|
||||
added to your image.
|
||||
</Alert>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome'
|
|||
|
||||
// Temporarily disable
|
||||
//import RepositoryUnavailable from './RepositoryUnavailable';
|
||||
import OscapProfileInformation from './OscapProfileInformation';
|
||||
import {
|
||||
ContentList,
|
||||
FSCList,
|
||||
ImageDetailsList,
|
||||
ImageOutputList,
|
||||
OscapList,
|
||||
RegisterLaterList,
|
||||
RegisterNowList,
|
||||
TargetEnvAWSList,
|
||||
|
|
@ -216,7 +216,7 @@ const ReviewStep = () => {
|
|||
isIndented
|
||||
data-testid="oscap-detail-expandable"
|
||||
>
|
||||
<OscapList />
|
||||
<OscapProfileInformation />
|
||||
</ExpandableSection>
|
||||
)}
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import {
|
|||
|
||||
import { RELEASES, UNIT_GIB } from '../../../constants';
|
||||
import { extractProvisioningList } from '../../../store/helpers';
|
||||
import { useGetOscapCustomizationsQuery } from '../../../store/imageBuilderApi';
|
||||
import { useGetSourceListQuery } from '../../../store/provisioningApi';
|
||||
import { useShowActivationKeyQuery } from '../../../store/rhsmApi';
|
||||
import { useGetEnvironment } from '../../../Utilities/useGetEnvironment';
|
||||
|
|
@ -615,51 +614,3 @@ export const ImageDetailsList = () => {
|
|||
</TextContent>
|
||||
);
|
||||
};
|
||||
|
||||
export const OscapList = () => {
|
||||
const { getState } = useFormApi();
|
||||
const oscapProfile = getState()?.values?.['oscap-profile'];
|
||||
const { data } = useGetOscapCustomizationsQuery({
|
||||
distribution: getState()?.values?.['release'],
|
||||
profile: oscapProfile,
|
||||
});
|
||||
|
||||
return (
|
||||
<TextContent>
|
||||
<TextList component={TextListVariants.dl}>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-u-min-width"
|
||||
>
|
||||
Profile name:
|
||||
</TextListItem>
|
||||
<TextListItem component={TextListItemVariants.dd}>
|
||||
{data?.openscap?.profile_name}
|
||||
</TextListItem>
|
||||
</TextList>
|
||||
<TextList component={TextListVariants.dl}>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-u-min-width"
|
||||
>
|
||||
Profile description:
|
||||
</TextListItem>
|
||||
<TextListItem component={TextListItemVariants.dd}>
|
||||
{data?.openscap?.profile_description}
|
||||
</TextListItem>
|
||||
</TextList>
|
||||
<TextList component={TextListVariants.dl}>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-u-min-width"
|
||||
>
|
||||
Reference ID:
|
||||
</TextListItem>
|
||||
<TextListItem component={TextListItemVariants.dd}>
|
||||
{oscapProfile}
|
||||
</TextListItem>
|
||||
</TextList>
|
||||
<br />
|
||||
</TextContent>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -153,6 +153,13 @@ describe('Step Compliance', () => {
|
|||
/cis red hat enterprise linux 8 benchmark for level 1 - workstation/i
|
||||
)
|
||||
);
|
||||
await screen.findByText(/kernel arguments:/i);
|
||||
await screen.findByText(/audit_backlog_limit=8192 audit=1/i);
|
||||
await screen.findByText(/disabled services:/i);
|
||||
await screen.findByText(/nfs-server/i);
|
||||
await screen.findByText(/enabled services:/i);
|
||||
await screen.findByText(/crond/i);
|
||||
|
||||
// check that the FSC contains a /tmp partition
|
||||
await clickNext();
|
||||
await screen.findByRole('heading', { name: /File system configuration/i });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue