diff --git a/libs/locales/lib/en/translation.json b/libs/locales/lib/en/translation.json index d97294a46c..9a5b24df19 100644 --- a/libs/locales/lib/en/translation.json +++ b/libs/locales/lib/en/translation.json @@ -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", diff --git a/libs/ui-lib/lib/cim/components/ClusterDeployment/networking/ClusterDeploymentNetworkingForm.tsx b/libs/ui-lib/lib/cim/components/ClusterDeployment/networking/ClusterDeploymentNetworkingForm.tsx index 79a443281b..26b7afed5d 100644 --- a/libs/ui-lib/lib/cim/components/ClusterDeployment/networking/ClusterDeploymentNetworkingForm.tsx +++ b/libs/ui-lib/lib/cim/components/ClusterDeployment/networking/ClusterDeploymentNetworkingForm.tsx @@ -157,7 +157,7 @@ const ClusterDeploymentNetworkingForm: React.FC - + diff --git a/libs/ui-lib/lib/cim/components/ClusterDeployment/use-networking-formik.ts b/libs/ui-lib/lib/cim/components/ClusterDeployment/use-networking-formik.ts index 834e5b6808..a1b226deb7 100644 --- a/libs/ui-lib/lib/cim/components/ClusterDeployment/use-networking-formik.ts +++ b/libs/ui-lib/lib/cim/components/ClusterDeployment/use-networking-formik.ts @@ -17,7 +17,7 @@ import { hostPrefixValidationSchema, ipBlockValidationSchema, vipArrayValidationSchema, - sshPublicKeyValidationSchema, + sshPublicKeyListValidationSchema, hostSubnetValidationSchema, httpProxyValidationSchema, noProxyValidationSchema, @@ -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 diff --git a/libs/ui-lib/lib/common/components/clusterConfiguration/SecurityFields.tsx b/libs/ui-lib/lib/common/components/clusterConfiguration/SecurityFields.tsx index 883eef3193..390da25b2f 100644 --- a/libs/ui-lib/lib/common/components/clusterConfiguration/SecurityFields.tsx +++ b/libs/ui-lib/lib/common/components/clusterConfiguration/SecurityFields.tsx @@ -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 ( - {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.', + )}{' '} {t('ai:Learn more')} @@ -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 @@ -77,7 +84,7 @@ const SecurityFields = ({ } + helperText={} onBlur={handleSshKeyBlur} isDisabled={isDisabled} /> diff --git a/libs/ui-lib/lib/common/components/ui/formik/validationSchemas.ts b/libs/ui-lib/lib/common/components/ui/formik/validationSchemas.ts index 54614c5b8a..0cc17f9426 100644 --- a/libs/ui-lib/lib/common/components/ui/formik/validationSchemas.ts +++ b/libs/ui-lib/lib/common/components/ui/formik/validationSchemas.ts @@ -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) => { diff --git a/libs/ui-lib/lib/ocm/components/clusterConfiguration/OcmDiscoveryImageConfigForm.tsx b/libs/ui-lib/lib/ocm/components/clusterConfiguration/OcmDiscoveryImageConfigForm.tsx index 05c4e1de26..60eeaeabe6 100644 --- a/libs/ui-lib/lib/ocm/components/clusterConfiguration/OcmDiscoveryImageConfigForm.tsx +++ b/libs/ui-lib/lib/ocm/components/clusterConfiguration/OcmDiscoveryImageConfigForm.tsx @@ -21,7 +21,7 @@ import { AlertFormikError, httpProxyValidationSchema, noProxyValidationSchema, - sshPublicKeyListValidationSchema, + sshPublicKeyValidationSchema, } from '../../../common/components/ui'; import { DiscoveryImageType, @@ -54,7 +54,7 @@ export type OcmDiscoveryImageFormValues = OcmImageCreateParams & const validationSchema = Yup.lazy((values: OcmDiscoveryImageFormValues) => Yup.object().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, diff --git a/libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/networkConfigurationValidation.ts b/libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/networkConfigurationValidation.ts index d7dab3f0e9..f6dd1beed8 100644 --- a/libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/networkConfigurationValidation.ts +++ b/libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/networkConfigurationValidation.ts @@ -9,7 +9,7 @@ import { NetworkConfigurationValues, serviceNetworkValidationSchema, IPv4ValidationSchema, - sshPublicKeyListValidationSchema, + sshPublicKeyValidationSchema, IPV4_STACK, DUAL_STACK, vipArrayValidationSchema, @@ -75,7 +75,7 @@ export const getNetworkConfigurationValidationSchema = ( values, initialValues.ingressVips, ), - sshPublicKey: sshPublicKeyListValidationSchema, + sshPublicKey: sshPublicKeyValidationSchema, machineNetworks: values.managedNetworkingType === 'userManaged' ? Yup.array()