mirror of https://github.com/portainer/portainer
fix(volumes): update external labels CE [r8s-108] (#7)
parent
57e10dc911
commit
fd0bc652a9
|
@ -38,6 +38,7 @@ type (
|
||||||
VolumeMode *corev1.PersistentVolumeMode `json:"volumeMode"`
|
VolumeMode *corev1.PersistentVolumeMode `json:"volumeMode"`
|
||||||
OwningApplications []K8sApplication `json:"owningApplications,omitempty"`
|
OwningApplications []K8sApplication `json:"owningApplications,omitempty"`
|
||||||
Phase corev1.PersistentVolumeClaimPhase `json:"phase"`
|
Phase corev1.PersistentVolumeClaimPhase `json:"phase"`
|
||||||
|
Labels map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
K8sStorageClass struct {
|
K8sStorageClass struct {
|
||||||
|
|
|
@ -135,6 +135,7 @@ func parsePersistentVolumeClaim(volume *corev1.PersistentVolumeClaim) models.K8s
|
||||||
VolumeMode: volume.Spec.VolumeMode,
|
VolumeMode: volume.Spec.VolumeMode,
|
||||||
OwningApplications: nil,
|
OwningApplications: nil,
|
||||||
Phase: volume.Status.Phase,
|
Phase: volume.Status.Phase,
|
||||||
|
Labels: volume.Labels,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import KubernetesEventHelper from 'Kubernetes/helpers/eventHelper';
|
||||||
import { KubernetesStorageClassAccessPolicies } from 'Kubernetes/models/storage-class/models';
|
import { KubernetesStorageClassAccessPolicies } from 'Kubernetes/models/storage-class/models';
|
||||||
import KubernetesNamespaceHelper from 'Kubernetes/helpers/namespaceHelper';
|
import KubernetesNamespaceHelper from 'Kubernetes/helpers/namespaceHelper';
|
||||||
import { confirmRedeploy } from '@/react/kubernetes/volumes/ItemView/ConfirmRedeployModal';
|
import { confirmRedeploy } from '@/react/kubernetes/volumes/ItemView/ConfirmRedeployModal';
|
||||||
import { isVolumeUsed, isVolumeExternal } from '@/react/kubernetes/volumes/utils';
|
import { isVolumeUsed } from '@/react/kubernetes/volumes/utils';
|
||||||
|
|
||||||
class KubernetesVolumeController {
|
class KubernetesVolumeController {
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
|
@ -50,7 +50,7 @@ class KubernetesVolumeController {
|
||||||
}
|
}
|
||||||
|
|
||||||
isExternalVolume() {
|
isExternalVolume() {
|
||||||
return isVolumeExternal(this.volume);
|
return !this.volume.PersistentVolumeClaim.ApplicationOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
isSystemNamespace() {
|
isSystemNamespace() {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { ExternalBadge } from '@@/Badge/ExternalBadge';
|
||||||
import { UnusedBadge } from '@@/Badge/UnusedBadge';
|
import { UnusedBadge } from '@@/Badge/UnusedBadge';
|
||||||
|
|
||||||
import { useNamespacesQuery } from '../../namespaces/queries/useNamespacesQuery';
|
import { useNamespacesQuery } from '../../namespaces/queries/useNamespacesQuery';
|
||||||
import { isVolumeExternal, isVolumeUsed } from '../utils';
|
import { isVolumeUsed } from '../utils';
|
||||||
|
|
||||||
import { VolumeViewModel } from './types';
|
import { VolumeViewModel } from './types';
|
||||||
import { helper } from './columns.helper';
|
import { helper } from './columns.helper';
|
||||||
|
@ -44,7 +44,7 @@ export function NameCell({
|
||||||
<SystemBadge />
|
<SystemBadge />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{isVolumeExternal(item) && <ExternalBadge />}
|
{item.PersistentVolumeClaim.IsExternal && <ExternalBadge />}
|
||||||
{!isVolumeUsed(item) && <UnusedBadge />}
|
{!isVolumeUsed(item) && <UnusedBadge />}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -13,6 +13,7 @@ export interface VolumeViewModel {
|
||||||
Storage?: unknown;
|
Storage?: unknown;
|
||||||
CreationDate?: string;
|
CreationDate?: string;
|
||||||
ApplicationOwner?: string;
|
ApplicationOwner?: string;
|
||||||
|
IsExternal?: boolean;
|
||||||
};
|
};
|
||||||
ResourcePool: {
|
ResourcePool: {
|
||||||
Namespace: {
|
Namespace: {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { Volume } from '@/kubernetes/models/volume/Volume';
|
||||||
import { parseKubernetesAxiosError } from '../../axiosError';
|
import { parseKubernetesAxiosError } from '../../axiosError';
|
||||||
import { K8sVolumeInfo } from '../types';
|
import { K8sVolumeInfo } from '../types';
|
||||||
import { VolumeViewModel, StorageClassViewModel } from '../ListView/types';
|
import { VolumeViewModel, StorageClassViewModel } from '../ListView/types';
|
||||||
|
import { appOwnerLabel } from '../../applications/constants';
|
||||||
|
|
||||||
import { queryKeys } from './query-keys';
|
import { queryKeys } from './query-keys';
|
||||||
|
|
||||||
|
@ -86,6 +87,7 @@ function convertToVolumeViewModels(
|
||||||
CreationDate: volume.persistentVolumeClaim.creationDate,
|
CreationDate: volume.persistentVolumeClaim.creationDate,
|
||||||
ApplicationOwner:
|
ApplicationOwner:
|
||||||
volume.persistentVolumeClaim.owningApplications?.[0]?.Name,
|
volume.persistentVolumeClaim.owningApplications?.[0]?.Name,
|
||||||
|
IsExternal: !volume.persistentVolumeClaim.labels?.[appOwnerLabel],
|
||||||
},
|
},
|
||||||
ResourcePool: {
|
ResourcePool: {
|
||||||
Namespace: {
|
Namespace: {
|
||||||
|
|
|
@ -37,6 +37,7 @@ interface K8sPersistentVolumeClaim {
|
||||||
volumeMode?: PersistentVolumeClaimSpec['volumeMode'];
|
volumeMode?: PersistentVolumeClaimSpec['volumeMode'];
|
||||||
owningApplications?: K8sVolOwningApplication[];
|
owningApplications?: K8sVolOwningApplication[];
|
||||||
phase: PersistentVolumeClaimStatus['phase'];
|
phase: PersistentVolumeClaimStatus['phase'];
|
||||||
|
labels?: { [key: string]: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
interface K8sStorageClass {
|
interface K8sStorageClass {
|
||||||
|
|
|
@ -6,10 +6,6 @@ export function isVolumeUsed(volume: VolumeViewModel) {
|
||||||
return volume.Applications.length !== 0;
|
return volume.Applications.length !== 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isVolumeExternal(volume: VolumeViewModel) {
|
|
||||||
return !volume.PersistentVolumeClaim.ApplicationOwner;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function generatedApplicationConfigVolumeName(applicationName: string) {
|
export function generatedApplicationConfigVolumeName(applicationName: string) {
|
||||||
return `config-${applicationName}-${uuidv4()}`;
|
return `config-${applicationName}-${uuidv4()}`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue