1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-04 21:35:23 +02:00

refactor(app): migrate configmap and secret form sections [EE-6233] (#10528)

* refactor(app): migrate configmap and secret form sections [EE-6233]
This commit is contained in:
Ali 2024-01-03 09:07:11 +13:00 committed by GitHub
parent 391b85da41
commit 7a2412b1be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 631 additions and 447 deletions

View file

@ -1,6 +1,9 @@
import { KeyToPath, Pod } from 'kubernetes-types/core/v1';
import { KeyToPath, Pod, Secret } from 'kubernetes-types/core/v1';
import { Asterisk, Plus } from 'lucide-react';
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
import { useSecrets } from '@/react/kubernetes/configs/secret.service';
import { Icon } from '@@/Icon';
import { Link } from '@@/Link';
@ -15,6 +18,8 @@ type Props = {
export function ApplicationVolumeConfigsTable({ namespace, app }: Props) {
const containerVolumeConfigs = getApplicationVolumeConfigs(app);
const { data: secrets } = useSecrets(useEnvironmentId(), namespace);
if (containerVolumeConfigs.length === 0) {
return null;
}
@ -71,10 +76,19 @@ export function ApplicationVolumeConfigsTable({ namespace, app }: Props) {
{!item.key && '-'}
</td>
<td>
{volumeConfigName && (
{isVolumeConfigNameFromSecret(secrets, volumeConfigName) ? (
<Link
className="flex items-center"
to="kubernetes.configurations.configuration"
to="kubernetes.secrets.secret"
params={{ name: volumeConfigName, namespace }}
>
<Icon icon={Plus} className="!mr-1" />
{volumeConfigName}
</Link>
) : (
<Link
className="flex items-center"
to="kubernetes.configmaps.configmap"
params={{ name: volumeConfigName, namespace }}
>
<Icon icon={Plus} className="!mr-1" />
@ -91,6 +105,13 @@ export function ApplicationVolumeConfigsTable({ namespace, app }: Props) {
);
}
function isVolumeConfigNameFromSecret(
secrets?: Secret[],
volumeConfigName?: string
) {
return secrets?.some((secret) => secret.metadata?.name === volumeConfigName);
}
// getApplicationVolumeConfigs returns a list of volume configs / secrets for each container and each item within the matching volume
function getApplicationVolumeConfigs(app?: Application) {
if (!app) {