Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libs/locales/lib/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,8 @@
"ai:Packet loss": "Packet loss",
"ai:Password": "Password",
"ai:Paste in 1 or more PEM formatted certificates that you want the cluster to trust.": "Paste in 1 or more PEM formatted certificates that you want the cluster to trust.",
"ai:Paste the content of a public ssh key you want to use to connect to the hosts into this field.": "Paste the content of a public ssh key you want to use to connect to the hosts into this field.",
"ai:Paste the content of a public SSH key you want to use to connect to the hosts into this field.": "Paste the content of a public SSH key you want to use to connect to the hosts into this field.",
"ai:Paste the content of public SSH keys you want to use to connect to the hosts into this field. Multiple keys can be separated by newlines.": "Paste the content of public SSH keys you want to use to connect to the hosts into this field. Multiple keys can be separated by newlines.",
"ai:Pending": "Pending",
"ai:Pending - {{operatorsCountString}}": "Pending - {{operatorsCountString}}",
"ai:Pending host assignment": "Pending host assignment",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const ClusterDeploymentNetworkingForm: React.FC<ClusterDeploymentNetworkingFormP
)}
</StackItem>
<StackItem>
<SecurityFields clusterSshKey={cluster.sshPublicKey} />
<SecurityFields clusterSshKey={cluster.sshPublicKey} allowMultipleKeys={true} />
</StackItem>
<StackItem>
<TextContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
hostPrefixValidationSchema,
ipBlockValidationSchema,
vipArrayValidationSchema,
sshPublicKeyValidationSchema,
sshPublicKeyListValidationSchema,
hostSubnetValidationSchema,
httpProxyValidationSchema,
noProxyValidationSchema,
Expand Down Expand Up @@ -52,7 +52,7 @@ const getNetworkConfigurationValidationSchema = (
serviceNetworkCidr: ipBlockValidationSchema(values.clusterNetworkCidr),
apiVips: vipArrayValidationSchema(hostSubnets, values, initialValues.apiVips),
ingressVips: vipArrayValidationSchema(hostSubnets, values, initialValues.ingressVips),
sshPublicKey: sshPublicKeyValidationSchema,
sshPublicKey: sshPublicKeyListValidationSchema,
hostSubnet: hostSubnetValidationSchema,
httpProxy: httpProxyValidationSchema({ values, pairValueName: 'httpsProxy' }),
httpsProxy: httpProxyValidationSchema({ values, pairValueName: 'httpProxy' }), // share the schema, httpS is currently not supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ import { useTranslation } from '../../hooks/use-translation-wrapper';

export const SshPublicKeyHelperText: React.FC<{
fieldId?: string;
}> = ({ fieldId = 'sshPublicKey' }) => {
allowMultipleKeys?: boolean;
}> = ({ fieldId = 'sshPublicKey', allowMultipleKeys = false }) => {
const { t } = useTranslation();
return (
<HelperText id={fieldId}>
<HelperTextItem>
{t(
'ai:Paste the content of a public ssh key you want to use to connect to the hosts into this field.',
)}{' '}
{allowMultipleKeys
? t(
'ai:Paste the content of public SSH keys you want to use to connect to the hosts into this field. Multiple keys can be separated by newlines.',
)
: t(
'ai:Paste the content of a public SSH key you want to use to connect to the hosts into this field.',
)}{' '}
<ExternalLink href={SSH_GENERATION_DOC_LINK}>{t('ai:Learn more')}</ExternalLink>
</HelperTextItem>
</HelperText>
Expand All @@ -29,12 +34,14 @@ interface SecurityFieldsFieldsProps {
clusterSshKey: Cluster['sshPublicKey'];
imageSshKey?: Cluster['imageInfo']['sshPublicKey'];
isDisabled?: boolean;
allowMultipleKeys?: boolean;
}

const SecurityFields = ({
clusterSshKey,
imageSshKey,
isDisabled = false,
allowMultipleKeys = false,
}: SecurityFieldsFieldsProps) => {
//shareSshKey shouldn't response to changes. imageSshKey stays the same, there's a loading state while it's requested
//clusterSshKey updating causes the textarea to disappear when the user clears it to edit it
Expand Down Expand Up @@ -77,7 +84,7 @@ const SecurityFields = ({
<RenderIf condition={!shareSshKey}>
<TextAreaField
name="sshPublicKey"
helperText={<SshPublicKeyHelperText />}
helperText={<SshPublicKeyHelperText allowMultipleKeys={allowMultipleKeys} />}
onBlur={handleSshKeyBlur}
isDisabled={isDisabled}
/>
Expand Down
14 changes: 6 additions & 8 deletions libs/ui-lib/lib/common/components/ui/formik/validationSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,12 @@ export const sshPublicKeyListValidationSchema = Yup.string()
if (!value) {
return true;
}
return !!trimSshPublicKey(value).match(SSH_PUBLIC_KEY_REGEX);

// disable until mutliple keys are supported (https://issues.redhat.com/browse/METAL-250)
// return (
// trimSshPublicKey(value)
// .split('\n')
// .find((line: string) => !line.match(SSH_PUBLIC_KEY_REGEX)) === undefined
// );

return (
trimSshPublicKey(value)
.split('\n')
.find((line: string) => !line.match(SSH_PUBLIC_KEY_REGEX)) === undefined
);
},
)
.test('ssh-public-keys-unique', 'SSH public keys must be unique.', (value?: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
AlertFormikError,
httpProxyValidationSchema,
noProxyValidationSchema,
sshPublicKeyListValidationSchema,
sshPublicKeyValidationSchema,
} from '../../../common/components/ui';
import {
DiscoveryImageType,
Expand Down Expand Up @@ -54,7 +54,7 @@ export type OcmDiscoveryImageFormValues = OcmImageCreateParams &

const validationSchema = Yup.lazy((values: OcmDiscoveryImageFormValues) =>
Yup.object<OcmDiscoveryImageFormValues>().shape({
sshPublicKey: sshPublicKeyListValidationSchema,
sshPublicKey: sshPublicKeyValidationSchema,
httpProxy: httpProxyValidationSchema({ values, pairValueName: 'httpsProxy' }),
httpsProxy: httpProxyValidationSchema({ values, pairValueName: 'httpProxy' }), // share the schema, httpS is currently not supported
noProxy: noProxyValidationSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
NetworkConfigurationValues,
serviceNetworkValidationSchema,
IPv4ValidationSchema,
sshPublicKeyListValidationSchema,
sshPublicKeyValidationSchema,
IPV4_STACK,
DUAL_STACK,
vipArrayValidationSchema,
Expand Down Expand Up @@ -75,7 +75,7 @@ export const getNetworkConfigurationValidationSchema = (
values,
initialValues.ingressVips,
),
sshPublicKey: sshPublicKeyListValidationSchema,
sshPublicKey: sshPublicKeyValidationSchema,
machineNetworks:
values.managedNetworkingType === 'userManaged'
? Yup.array()
Expand Down
Loading