Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐾 Allow to fetch CA from URL for all providers #953

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const CertificateUpload: FC<CertificateUploadProps> = ({
<FlexItem>
<Button
className="forklift-certificate-upload-margin"
isDisabled={isDisabled}
isDisabled={isDisabled || !url?.trim().startsWith('https://')}
variant="secondary"
onClick={() =>
showModal(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { ModalHOC } from 'src/modules/Providers/modals';
import { useForkliftTranslation } from 'src/utils/i18n';

import {
Expand Down Expand Up @@ -55,12 +54,12 @@ export const EditProvider: React.FC<ProvidersCreateFormProps> = ({
);
case 'vsphere':
return (
<ModalHOC>
<>
<VSphereProviderCreateForm provider={newProvider} onChange={onNewProviderChange} />

<EditProviderSectionHeading text={t('Provider credentials')} />
<VSphereCredentialsEdit secret={newSecret} onChange={onNewSecretChange} />
</ModalHOC>
</>
);
case 'ova':
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useReducer } from 'react';
import { Base64 } from 'js-base64';
import { ModalHOC } from 'src/modules/Providers/modals';
import { validateK8sName, ValidationMsg } from 'src/modules/Providers/utils';
import { SelectableCard } from 'src/modules/Providers/utils/components/Galerry/SelectableCard';
import { SelectableGallery } from 'src/modules/Providers/utils/components/Galerry/SelectableGallery';
Expand Down Expand Up @@ -84,7 +85,7 @@ export const ProvidersCreateForm: React.FC<ProvidersCreateFormProps> = ({
};

return (
<>
<ModalHOC>
<div className="forklift-create-provider-edit-section">
<EditProviderSectionHeading text={t('Provider details')} />

Expand Down Expand Up @@ -144,7 +145,7 @@ export const ProvidersCreateForm: React.FC<ProvidersCreateFormProps> = ({
onNewSecretChange={onNewSecretChange}
/>
</div>
</>
</ModalHOC>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { ModalHOC } from 'src/modules/Providers/modals';
import { ProviderData } from 'src/modules/Providers/utils';
import { useForkliftTranslation } from 'src/utils/i18n';

Expand Down Expand Up @@ -40,11 +41,13 @@ export const CredentialsSection: React.FC<CredentialsProps> = (props) => {
}

return (
<CredentialsSection_
name={provider?.spec?.secret?.name}
namespace={provider?.spec?.secret?.namespace}
type={provider?.spec?.type}
/>
<ModalHOC>
<CredentialsSection_
name={provider?.spec?.secret?.name}
namespace={provider?.spec?.secret?.namespace}
type={provider?.spec?.type}
/>
</ModalHOC>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useCallback, useReducer } from 'react';
import { Base64 } from 'js-base64';
import { openshiftSecretFieldValidator, safeBase64Decode } from 'src/modules/Providers/utils';
import { CertificateUpload } from 'src/modules/Providers/utils/components/CertificateUpload';
import { ForkliftTrans, useForkliftTranslation } from 'src/utils/i18n';

import {
Button,
Divider,
FileUpload,
Form,
FormGroup,
Popover,
Expand All @@ -22,6 +22,7 @@ import { EditComponentProps } from '../BaseCredentialsSection';
export const OpenshiftCredentialsEdit: React.FC<EditComponentProps> = ({ secret, onChange }) => {
const { t } = useForkliftTranslation();

const url = safeBase64Decode(secret?.data?.url || '');
const token = safeBase64Decode(secret?.data?.token || '');
const insecureSkipVerify = safeBase64Decode(secret?.data?.insecureSkipVerify || '') === 'true';
const cacert = safeBase64Decode(secret?.data?.cacert || '');
Expand Down Expand Up @@ -190,7 +191,7 @@ export const OpenshiftCredentialsEdit: React.FC<EditComponentProps> = ({ secret,
helperTextInvalid={state.validation.cacert.msg}
validated={state.validation.cacert.type}
>
<FileUpload
<CertificateUpload
id="cacert"
type="text"
filenamePlaceholder="Drag and drop a file or upload one"
Expand All @@ -200,6 +201,7 @@ export const OpenshiftCredentialsEdit: React.FC<EditComponentProps> = ({ secret,
onTextChange={(value) => handleChange('cacert', value)}
onClearClick={() => handleChange('cacert', '')}
browseButtonText="Upload"
url={url}
isDisabled={insecureSkipVerify}
/>
</FormGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import React, { useCallback, useReducer } from 'react';
import { Base64 } from 'js-base64';
import { openstackSecretFieldValidator, safeBase64Decode } from 'src/modules/Providers/utils';
import { CertificateUpload } from 'src/modules/Providers/utils/components/CertificateUpload';
import { ForkliftTrans, useForkliftTranslation } from 'src/utils/i18n';

import {
Divider,
FileUpload,
Form,
FormGroup,
Popover,
Radio,
Switch,
} from '@patternfly/react-core';
import { Divider, Form, FormGroup, Popover, Radio, Switch } from '@patternfly/react-core';
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';

import { EditComponentProps } from '../BaseCredentialsSection';
Expand Down Expand Up @@ -50,6 +43,7 @@ export const OpenstackCredentialsEdit: React.FC<EditComponentProps> = ({ secret,
</ForkliftTrans>
);

const url = safeBase64Decode(secret?.data?.url || '');
const authType = safeBase64Decode(secret?.data?.authType || '');
const username = safeBase64Decode(secret?.data?.username || '');
const insecureSkipVerify = safeBase64Decode(secret?.data?.insecureSkipVerify || '') === 'true';
Expand Down Expand Up @@ -288,7 +282,7 @@ export const OpenstackCredentialsEdit: React.FC<EditComponentProps> = ({ secret,
validated={state.validation.cacert}
helperTextInvalid={cacertHelperTextMsgs.error}
>
<FileUpload
<CertificateUpload
id="cacert"
type="text"
filenamePlaceholder="Drag and drop a file or upload one"
Expand All @@ -298,6 +292,7 @@ export const OpenstackCredentialsEdit: React.FC<EditComponentProps> = ({ secret,
onTextChange={(value) => handleChange('cacert', value)}
onClearClick={() => handleChange('cacert', '')}
browseButtonText="Upload"
url={url}
isDisabled={insecureSkipVerify}
/>
</FormGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useCallback, useReducer } from 'react';
import { Base64 } from 'js-base64';
import { ovirtSecretFieldValidator, safeBase64Decode } from 'src/modules/Providers/utils';
import { CertificateUpload } from 'src/modules/Providers/utils/components/CertificateUpload';
import { ForkliftTrans, useForkliftTranslation } from 'src/utils/i18n';

import {
Button,
Divider,
FileUpload,
Form,
FormGroup,
Popover,
Expand All @@ -23,6 +23,7 @@ export const OvirtCredentialsEdit: React.FC<EditComponentProps> = ({ secret, onC
const { t } = useForkliftTranslation();

const user = safeBase64Decode(secret?.data?.user || '');
const url = safeBase64Decode(secret?.data?.url || '');
const password = safeBase64Decode(secret?.data?.password || '');
const insecureSkipVerify = safeBase64Decode(secret?.data?.insecureSkipVerify || '') === 'true';
const cacert = safeBase64Decode(secret?.data?.cacert || '');
Expand Down Expand Up @@ -216,7 +217,7 @@ export const OvirtCredentialsEdit: React.FC<EditComponentProps> = ({ secret, onC
helperTextInvalid={state.validation.cacert.msg}
validated={state.validation.cacert.type}
>
<FileUpload
<CertificateUpload
id="cacert"
type="text"
filenamePlaceholder="Drag and drop a file or upload one"
Expand All @@ -226,6 +227,7 @@ export const OvirtCredentialsEdit: React.FC<EditComponentProps> = ({ secret, onC
onTextChange={(value) => handleChange('cacert', value)}
onClearClick={() => handleChange('cacert', '')}
browseButtonText="Upload"
url={url}
isDisabled={insecureSkipVerify}
/>
</FormGroup>
Expand Down
Loading