Skip to content
Open
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
13 changes: 12 additions & 1 deletion frontend/packages/helm-plugin/locales/en/helm-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"**Helm Charts** are packages for deploying an Application or components of a larger Application.": "**Helm Charts** are packages for deploying an Application or components of a larger Application.",
"A description for the Helm Chart repository.": "A description for the Helm Chart repository.",
"A display name for the Helm Chart repository.": "A display name for the Helm Chart repository.",
"A secret with \"username\" and \"password\" keys for OCI/HTTP(S) authentication": "A secret with \"username\" and \"password\" keys for OCI/HTTP(S) authentication",
"A unique name for the Helm Chart repository.": "A unique name for the Helm Chart repository.",
"A unique name for the Helm Release.": "A unique name for the Helm Release.",
"Add a Helm Chart Repository to extend the Developer Catalog": "Add a Helm Chart Repository to extend the Developer Catalog",
Expand Down Expand Up @@ -39,9 +38,11 @@
"Complete the form to create a Helm release. The Helm chart authors might have provided some default values.": "Complete the form to create a Helm release. The Helm chart authors might have provided some default values.",
"Configure Helm release": "Configure Helm release",
"Create": "Create",
"Create authentication Secret": "Create authentication Secret",
"Create Helm Chart Repository": "Create Helm Chart Repository",
"Create Helm Release": "Create Helm Release",
"Create ProjectHelmChartRepository": "Create ProjectHelmChartRepository",
"Create Secret": "Create Secret",
"Created": "Created",
"Delete": "Delete",
"Delete Helm Release": "Delete Helm Release",
Expand All @@ -55,6 +56,7 @@
"Edit Helm Chart Repository": "Edit Helm Chart Repository",
"Edit ProjectHelmChartRepository": "Edit ProjectHelmChartRepository",
"Errors in the form data.": "Errors in the form data.",
"Failed to create Secret.": "Failed to create Secret.",
"False": "False",
"Filter by status": "Filter by status",
"For more information on the chart, refer to this <2>README</2>": "For more information on the chart, refer to this <2>README</2>",
Expand Down Expand Up @@ -100,6 +102,7 @@
"None": "None",
"of": "of",
"Partner": "Partner",
"Password or token for OCI/HTTP(S) authentication.": "Password or token for OCI/HTTP(S) authentication.",
"per page": "per page",
"Please enter a URL that is less then 2048 characters.": "Please enter a URL that is less then 2048 characters.",
"Pods": "Pods",
Expand All @@ -126,7 +129,12 @@
"Rollback to Revision {{revision}}": "Rollback to Revision {{revision}}",
"Save": "Save",
"Scope type": "Scope type",
"Secret \"{{secretName}}\" was not found in this namespace. Select an existing secret or create a new one.": "Secret \"{{secretName}}\" was not found in this namespace. Select an existing secret or create a new one.",
"Secret for Basic authentication": "Secret for Basic authentication",
"Secret name": "Secret name",
"Secret password or token": "Secret password or token",
"Secret username": "Secret username",
"Secret with \"{{username}}\" and \"{{password}}\" keys for OCI/HTTP(S) authentication.": "Secret with \"{{username}}\" and \"{{password}}\" keys for OCI/HTTP(S) authentication.",
"Select": "Select",
"Select a Project to view its details<1></1>.": "Select a Project to view its details<1></1>.",
"Select a secret": "Select a secret",
Expand All @@ -146,6 +154,7 @@
"The repository name cannot exceed than 2048 characters.": "The repository name cannot exceed than 2048 characters.",
"The version of chart to install.": "The version of chart to install.",
"This Helm Chart is provided by a trusted partner and has been verified for ease of integration.": "This Helm Chart is provided by a trusted partner and has been verified for ease of integration.",
"This name is reserved. Choose a different name.": "This name is reserved. Choose a different name.",
"TLS Client config": "TLS Client config",
"To install a Helm chart, enter the chart URL - Open Container Initiative (OCI) URL or HTTP/HTTPS tar file and version.": "To install a Helm chart, enter the chart URL - Open Container Initiative (OCI) URL or HTTP/HTTPS tar file and version.",
"True": "True",
Expand All @@ -154,6 +163,7 @@
"Unable to load Helm Release history": "Unable to load Helm Release history",
"Unable to load Helm Releases": "Unable to load Helm Releases",
"Unique name for Helm release.": "Unique name for Helm release.",
"Unique name of the Secret": "Unique name of the Secret",
"Unknown error submitting": "Unknown error submitting",
"Update helm chart repository in the namespace.": "Update helm chart repository in the namespace.",
"Update the helm chart repository.": "Update the helm chart repository.",
Expand All @@ -163,6 +173,7 @@
"Upgrade by selecting a new chart version or manually changing YAML.": "Upgrade by selecting a new chart version or manually changing YAML.",
"Upgrade Helm Release": "Upgrade Helm Release",
"URL": "URL",
"Username for OCI/HTTP(S) authentication.": "Username for OCI/HTTP(S) authentication.",
"Values from your current release are merged with the new chart's defaults. Review the YAML or form before upgrading.": "Values from your current release are merged with the new chart's defaults. Review the YAML or form before upgrading.",
"Version": "Version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ReactNode, FC } from 'react';
import { useMemo } from 'react';
import { TextInputTypes, Grid, GridItem, Button, Alert } from '@patternfly/react-core';
import type { FormikProps } from 'formik';
import * as fuzzy from 'fuzzysearch';
import type { JSONSchema7 } from 'json-schema';
import * as _ from 'lodash';
import { Trans, useTranslation } from 'react-i18next';
Expand All @@ -14,11 +15,18 @@ import { FormHeader } from '@console/shared/src/components/form-utils/FormHeader
import { CodeEditorField } from '@console/shared/src/components/formik-fields/CodeEditorField';
import { DynamicFormField } from '@console/shared/src/components/formik-fields/DynamicFormField';
import { InputField } from '@console/shared/src/components/formik-fields/InputField';
import { ResourceDropdownField } from '@console/shared/src/components/formik-fields/ResourceDropdownField';
import { SyncedEditorField } from '@console/shared/src/components/formik-fields/SyncedEditorField';
import type { EditorType } from '@console/shared/src/components/synced-editor/editor-toggle';
import type { HelmChart, HelmActionConfigType } from '../../../types/helm-types';
import { HelmActionType } from '../../../types/helm-types';
import { helmActionString } from '../../../utils/helm-utils';
import {
useBasicAuthSecretDropdown,
CREATE_SECRET_KEY,
NONE_SECRET_KEY,
} from '../url-chart/useBasicAuthSecretDropdown';
import { useSecretResources } from '../url-chart/useSecretResources';
import HelmChartVersionDropdown from './HelmChartVersionDropdown';
import { useHelmReadmeModalLauncher } from './HelmReadmeModal';

Expand All @@ -35,6 +43,8 @@ export type HelmInstallUpgradeFormData = {
formData: any;
formSchema: JSONSchema7;
editorType: EditorType;
basicAuthSecretName?: string;
isURLInstall?: boolean;
};

interface HelmInstallUpgradeFormProps {
Expand Down Expand Up @@ -68,11 +78,33 @@ const HelmInstallUpgradeForm: FC<
chartIndexEntry,
annotatedName,
providerName,
setFieldValue,
}) => {
const { t } = useTranslation('helm-plugin');
const { handleSecretChange } = useBasicAuthSecretDropdown({
namespace,
currentSecretName: values.basicAuthSecretName,
setFieldValue,
});
const { chartName, chartVersion, chartReadme, formData, formSchema, editorType } = values;
const { type: helmAction, title, subTitle } = helmActionConfig;
const helmReadmeModalLauncher = useHelmReadmeModalLauncher({ readme: chartReadme });
const showAuthSecret = values.isURLInstall;
const secretResources = useSecretResources(namespace);
const autocompleteFilter = (strText: string, item: any, key?: string): boolean =>
fuzzy(strText, item?.props?.name || (typeof item === 'string' ? item : key) || '');
const secretMissing = useMemo(() => {
if (
!showAuthSecret ||
!values.basicAuthSecretName ||
values.basicAuthSecretName === NONE_SECRET_KEY ||
!secretResources[0]?.loaded
) {
return false;
}
const secrets = secretResources[0]?.data ?? [];
return !secrets.some((s) => s?.metadata?.name === values.basicAuthSecretName);
}, [showAuthSecret, secretResources, values.basicAuthSecretName]);
const isSubmitDisabled =
(helmAction === HelmActionType.Upgrade && !dirty) ||
isSubmitting ||
Expand Down Expand Up @@ -162,6 +194,48 @@ const HelmInstallUpgradeForm: FC<
providerName={providerName}
/>
</GridItem>
{showAuthSecret && (
<GridItem xl={5} lg={4} md={12}>
<ResourceDropdownField
name="basicAuthSecretName"
label={t('Secret for Basic authentication')}
resources={secretResources}
dataSelector={['metadata', 'name']}
fullWidth
placeholder={
helmAction === HelmActionType.Upgrade ? t('None') : t('Select a secret')
}
showBadge
autocompleteFilter={autocompleteFilter}
actionItems={[
{
actionTitle: t('None'),
actionKey: NONE_SECRET_KEY,
},
{
actionTitle: t('Create Secret'),
actionKey: CREATE_SECRET_KEY,
},
]}
onChange={handleSecretChange}
helpText={t(
'Secret with "{{username}}" and "{{password}}" keys for OCI/HTTP(S) authentication.',
{ username: 'username', password: 'password' },
)}
/>
{secretMissing && (
<Alert
variant="warning"
isInline
isPlain
title={t(
'Secret "{{secretName}}" was not found in this namespace. Select an existing secret or create a new one.',
{ secretName: values.basicAuthSecretName },
)}
/>
)}
</GridItem>
)}
</Grid>
</FormSection>
{!chartError &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
isGoingToTopology,
} from '../../../utils/helm-utils';
import { getHelmActionValidationSchema } from '../../../utils/helm-validation-utils';
import { NONE_SECRET_KEY } from '../url-chart/useBasicAuthSecretDropdown';
import HelmChartMetaDescription from './HelmChartMetaDescription';
import type { HelmInstallUpgradeFormData } from './HelmInstallUpgradeForm';
import HelmInstallUpgradeForm from './HelmInstallUpgradeForm';
Expand Down Expand Up @@ -65,6 +66,7 @@ const HelmInstallUpgradePage: FC = () => {
const [initialYamlData, setInitialYamlData] = useState<string>('');
const [initialFormData, setInitialFormData] = useState<object>();
const [initialFormSchema, setInitialFormSchema] = useState<JSONSchema7>();
const [initialBasicAuthSecretName, setInitialBasicAuthSecretName] = useState<string>('');
const helmAction: HelmActionType = initialChartURL
? HelmActionType.Create
: HelmActionType.Upgrade;
Expand Down Expand Up @@ -101,6 +103,9 @@ const HelmInstallUpgradePage: FC = () => {
const valuesYAML = releaseValues || chartValues;
const valuesJSON = (res?.config || chart?.values) ?? {};
const valuesSchema = chart?.schema && JSON.parse(atob(chart?.schema));
const basicAuthSecretName =
chart?.metadata?.annotations?.['helm.openshift.io/auth-secret'] ?? '';
setInitialBasicAuthSecretName(basicAuthSecretName);
setInitialYamlData(valuesYAML);
setInitialFormData(valuesJSON);
setInitialFormSchema(valuesSchema);
Expand All @@ -120,6 +125,8 @@ const HelmInstallUpgradePage: FC = () => {
};
}, [config.helmReleaseApi, helmAction]);

const isURLInstall = chartData?.metadata?.annotations?.installation === 'url_install';

const initialValues: HelmInstallUpgradeFormData = {
releaseName: initialReleaseName || helmChartName || '',
chartURL: initialChartURL,
Expand All @@ -133,6 +140,8 @@ const HelmInstallUpgradePage: FC = () => {
formData: initialFormData,
formSchema: initialFormSchema,
editorType: initialFormSchema ? EditorType.Form : EditorType.YAML,
basicAuthSecretName: initialBasicAuthSecretName,
isURLInstall,
};

const handleSubmit = (values, actions) => {
Expand All @@ -143,6 +152,7 @@ const HelmInstallUpgradePage: FC = () => {
yamlData,
formData,
editorType,
basicAuthSecretName,
}: HelmInstallUpgradeFormData = values;
let valuesObj;

Expand Down Expand Up @@ -182,6 +192,14 @@ const HelmInstallUpgradePage: FC = () => {
...(chartURL ? { chart_url: chartURL } : {}), // eslint-disable-line @typescript-eslint/naming-convention
...(indexEntry ? { indexEntry } : { indexEntry: chartIndexEntry }),
...(valuesObj ? { values: valuesObj } : {}),
...(values.isURLInstall
? {
basic_auth_secret_name:
helmAction === HelmActionType.Create && basicAuthSecretName === NONE_SECRET_KEY
? ''
: basicAuthSecretName,
}
: {}), // eslint-disable-line @typescript-eslint/naming-convention
};

return config
Expand Down
Loading