From fcccbfbbb952856ce8bfeeed0c5cbc769873fca2 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Fri, 11 Mar 2022 12:34:20 -0500 Subject: [PATCH] move variants into seperate files Signed-off-by: Sebastian Malton --- src/common/k8s-api/endpoints/pods.api.ts | 18 +- .../details/volumes/variant-helpers.tsx | 40 ++ .../details/volumes/variant.tsx | 50 ++ .../details/volumes/variants.tsx | 80 +++ .../variants/aws-elastic-block-store.tsx | 21 + .../details/volumes/variants/azure-disk.tsx | 32 + .../details/volumes/variants/azure-file.tsx | 26 + .../details/volumes/variants/ceph-fs.tsx | 46 ++ .../details/volumes/variants/cinder.tsx | 21 + .../details/volumes/variants/config-map.tsx | 19 + .../variants/container-storage-interface.tsx | 67 ++ .../details/volumes/variants/downward-api.tsx | 20 + .../details/volumes/variants/empty-dir.tsx | 20 + .../details/volumes/variants/ephemeral.tsx | 29 + .../volumes/variants/fiber-channel.tsx | 29 + .../details/volumes/variants/flex-volume.tsx | 39 ++ .../details/volumes/variants/flocker.tsx | 18 + .../volumes/variants/gce-persistent-disk.tsx | 21 + .../details/volumes/variants/git-repo.tsx | 21 + .../details/volumes/variants/gluster-fs.tsx | 24 + .../details/volumes/variants/host-path.tsx | 21 + .../details/volumes/variants/i-scsi.tsx | 45 ++ .../details/volumes/variants/local.tsx | 18 + .../details/volumes/variants/network-fs.tsx | 24 + .../variants/persistent-volume-claim.tsx | 19 + .../variants/photon-persistent-disk.tsx | 21 + .../volumes/variants/portworx-volume.tsx | 24 + .../details/volumes/variants/projected.tsx | 82 +++ .../details/volumes/variants/quobyte.tsx | 33 + .../volumes/variants/rados-block-device.tsx | 52 ++ .../details/volumes/variants/scale-io.tsx | 52 ++ .../details/volumes/variants/secret.tsx | 33 + .../details/volumes/variants/storage-os.tsx | 38 + .../volumes/variants/vsphere-volume.tsx | 27 + .../+workloads-pods/details/volumes/view.tsx | 38 + .../+workloads-pods/pod-details-volumes.tsx | 658 ------------------ .../+workloads-pods/pod-details.tsx | 2 +- .../components/drawer/drawer-item.tsx | 4 +- 38 files changed, 1162 insertions(+), 670 deletions(-) create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variant-helpers.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variant.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/aws-elastic-block-store.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/azure-disk.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/azure-file.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/ceph-fs.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/cinder.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/config-map.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/container-storage-interface.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/downward-api.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/empty-dir.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/ephemeral.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/fiber-channel.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/flex-volume.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/flocker.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/gce-persistent-disk.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/git-repo.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/gluster-fs.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/host-path.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/i-scsi.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/local.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/network-fs.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/persistent-volume-claim.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/photon-persistent-disk.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/portworx-volume.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/projected.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/quobyte.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/rados-block-device.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/scale-io.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/secret.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/storage-os.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/variants/vsphere-volume.tsx create mode 100644 src/renderer/components/+workloads-pods/details/volumes/view.tsx delete mode 100644 src/renderer/components/+workloads-pods/pod-details-volumes.tsx diff --git a/src/common/k8s-api/endpoints/pods.api.ts b/src/common/k8s-api/endpoints/pods.api.ts index 6226deb59e..78a9480362 100644 --- a/src/common/k8s-api/endpoints/pods.api.ts +++ b/src/common/k8s-api/endpoints/pods.api.ts @@ -389,7 +389,7 @@ export interface HostPathSource { type?: "" | "DirectoryOrCreate" | "Directory" | "FileOrCreate" | "File" | "Socket" | "CharDevice" | "BlockDevice"; } -export interface IscsiSource { +export interface IScsiSource { targetPortal: string; iqn: string; lun: number; @@ -410,7 +410,7 @@ export interface NetworkFsSource { readOnly?: boolean; } -export interface PVCSource { +export interface PersistentVolumeClaimSource { claimName: string; } @@ -485,7 +485,7 @@ export interface QuobyteSource { tenant?: string; } -export interface RbdSource { +export interface RadosBlockDeviceSource { monitors: string[]; image: string; /** @@ -598,30 +598,30 @@ export interface PodVolumeVariants { cephfs: CephfsSource; cinder: CinderSource; configMap: ConfigMapSource; + csi: ContainerStorageInterfaceSource; downwardAPI: DownwardApiSource; - ephemeral: EphemeralSource; emptyDir: EmptyDirSource; + ephemeral: EphemeralSource; fc: FiberChannelSource; - flocker: FlokerSource; flexVolume: FlexVolumeSource; + flocker: FlokerSource; gcePersistentDisk: GcePersistentDiskSource; gitRepo: GitRepoSource; glusterfs: GlusterFsSource; hostPath: HostPathSource; - iscsi: IscsiSource; + iscsi: IScsiSource; local: LocalSource; nfs: NetworkFsSource; - persistentVolumeClaim: PVCSource; + persistentVolumeClaim: PersistentVolumeClaimSource; photonPersistentDisk: PhotonPersistentDiskSource; portworxVolume: PortworxVolumeSource; projected: ProjectedSource; quobyte: QuobyteSource; - rbd: RbdSource; + rbd: RadosBlockDeviceSource; scaleIO: ScaleIoSource; secret: SecretSource; storageos: StorageOsSource; vsphereVolume: VsphereVolumeSource; - csi: ContainerStorageInterfaceSource; } /** diff --git a/src/renderer/components/+workloads-pods/details/volumes/variant-helpers.tsx b/src/renderer/components/+workloads-pods/details/volumes/variant-helpers.tsx new file mode 100644 index 0000000000..30dd552f9d --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variant-helpers.tsx @@ -0,0 +1,40 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import React from "react"; +import { Link } from "react-router-dom"; +import type { PodVolumeVariants, Pod, SecretReference } from "../../../../../common/k8s-api/endpoints"; +import type { KubeApi } from "../../../../../common/k8s-api/kube-api"; +import type { LocalObjectReference, KubeObject } from "../../../../../common/k8s-api/kube-object"; +import { DrawerItem } from "../../../drawer"; +import { getDetailsUrl } from "../../../kube-detail-params"; + +export interface PodVolumeVariantSpecificProps { + variant: PodVolumeVariants[Kind]; + pod: Pod; + volumeName: string; +} + +export type VolumeVariantComponent = React.FunctionComponent>; + +export interface LocalRefProps { + pod: Pod; + title: string; + ref: LocalObjectReference | SecretReference | undefined; + api: KubeApi; +} + +export const LocalRef = ({ pod, title, ref, api }: LocalRefProps) => { + if (!ref) { + return null; + } + + return ( + + + {ref.name} + + + ); +}; diff --git a/src/renderer/components/+workloads-pods/details/volumes/variant.tsx b/src/renderer/components/+workloads-pods/details/volumes/variant.tsx new file mode 100644 index 0000000000..ec74068538 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variant.tsx @@ -0,0 +1,50 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import type { Pod, PodVolume, PodVolumeKind } from "../../../../../common/k8s-api/endpoints"; +import { entries } from "../../../../utils"; +import { DrawerItem } from "../../../drawer"; +import { Icon } from "../../../icon"; +import getVolumeVariantComponent from "./variants"; + +const deprecatedVolumeTypes = new Set([ + "flocker", + "gitRepo", + "quobyte", + "storageos", +]); + +interface VolumeVarientProps { + pod: Pod; + volume: PodVolume; +} + +export function VolumeVarient({ pod, volume }: VolumeVarientProps) { + for (const [kind, variant] of entries(volume)) { + if (kind === "name") { + continue; // This key is not a kind field + } + + if (!variant || typeof variant !== "object") { + continue; + } + + const isDeprecated = deprecatedVolumeTypes.has(kind); + const VolumeVariantComponent = getVolumeVariantComponent(kind); + + return ( + <> + + {kind} + {isDeprecated && } + + + + ); + } + + return

Error! Unknown pod volume kind

; +} diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants.tsx new file mode 100644 index 0000000000..7ff3f0427a --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants.tsx @@ -0,0 +1,80 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import type { PodVolumeKind, PodVolumeVariants } from "../../../../../common/k8s-api/endpoints"; +import type { VolumeVariantComponent } from "./variant-helpers"; +import { AwsElasticBlockStore } from "./variants/aws-elastic-block-store"; +import { AzureDisk } from "./variants/azure-disk"; +import { AzureFile } from "./variants/azure-file"; +import { CephFs } from "./variants/ceph-fs"; +import { Cinder } from "./variants/cinder"; +import { ConfigMap } from "./variants/config-map"; +import { ContainerStorageInterface } from "./variants/container-storage-interface"; +import { DownwardApi } from "./variants/downward-api"; +import { EmptyDir } from "./variants/empty-dir"; +import { Ephemeral } from "./variants/ephemeral"; +import { FiberChannel } from "./variants/fiber-channel"; +import { FlexVolume } from "./variants/flex-volume"; +import { Flocker } from "./variants/flocker"; +import { GcePersistentDisk } from "./variants/gce-persistent-disk"; +import { GitRepo } from "./variants/git-repo"; +import { GlusterFs } from "./variants/gluster-fs"; +import { HostPath } from "./variants/host-path"; +import { IScsi } from "./variants/i-scsi"; +import { Local } from "./variants/local"; +import { NetworkFs } from "./variants/network-fs"; +import { PersistentVolumeClaim } from "./variants/persistent-volume-claim"; +import { PhotonPersistentDisk } from "./variants/photon-persistent-disk"; +import { PortworxVolume } from "./variants/portworx-volume"; +import { Projected } from "./variants/projected"; +import { Quobyte } from "./variants/quobyte"; +import { RadosBlockDevice } from "./variants/rados-block-device"; +import { ScaleIo } from "./variants/scale-io"; +import { Secret } from "./variants/secret"; +import { StorageOs } from "./variants/storage-os"; +import { VsphereVolume } from "./variants/vsphere-volume"; + +const variantComponents = new Map>([ + ["awsElasticBlockStore", AwsElasticBlockStore], + ["azureDisk", AzureDisk], + ["azureFile", AzureFile], + ["cephfs", CephFs], + ["cinder", Cinder], + ["configMap", ConfigMap], + ["csi", ContainerStorageInterface], + ["downwardAPI", DownwardApi], + ["emptyDir", EmptyDir], + ["ephemeral", Ephemeral], + ["fc", FiberChannel], + ["flexVolume", FlexVolume], + ["flocker", Flocker], + ["gcePersistentDisk", GcePersistentDisk], + ["gitRepo", GitRepo], + ["glusterfs", GlusterFs], + ["hostPath", HostPath], + ["iscsi", IScsi], + ["local", Local], + ["nfs", NetworkFs], + ["persistentVolumeClaim", PersistentVolumeClaim], + ["photonPersistentDisk", PhotonPersistentDisk], + ["portworxVolume", PortworxVolume], + ["projected", Projected], + ["quobyte", Quobyte], + ["rbd", RadosBlockDevice], + ["scaleIO", ScaleIo], + ["secret", Secret], + ["storageos", StorageOs], + ["vsphereVolume", VsphereVolume], +]); + + +export default function getVolumeVariantComponent(kind: PodVolumeKind) { + const NotSupported: VolumeVariantComponent = ( + () =>

Variant {kind} is not yet supported

+ ); + + return variantComponents.get(kind) ?? NotSupported; +} diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/aws-elastic-block-store.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/aws-elastic-block-store.tsx new file mode 100644 index 0000000000..285a0fa12e --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/aws-elastic-block-store.tsx @@ -0,0 +1,21 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const AwsElasticBlockStore: VolumeVariantComponent<"awsElasticBlockStore"> = ( + ({ variant: { volumeID, fsType = "ext4" }}) => ( + <> + + {volumeID} + + + {fsType} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/azure-disk.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/azure-disk.tsx new file mode 100644 index 0000000000..0e19b41843 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/azure-disk.tsx @@ -0,0 +1,32 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const AzureDisk: VolumeVariantComponent<"azureDisk"> = ( + ({ variant: { diskName, diskURI, kind = "Shared", cachingMode = "None", fsType = "ext4", readonly = false }}) => ( + <> + + {diskName} + + + {diskURI} + + + {kind} + + + {cachingMode} + + + {fsType} + + + {readonly.toString()} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/azure-file.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/azure-file.tsx new file mode 100644 index 0000000000..c73fd42c02 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/azure-file.tsx @@ -0,0 +1,26 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const AzureFile: VolumeVariantComponent<"azureFile"> = ( + ({ variant: { readOnly = false, secretName, shareName, secretNamespace = "default" }}) => ( + <> + + {secretName} + + + {shareName} + + + {secretNamespace} + + + {readOnly.toString()} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/ceph-fs.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/ceph-fs.tsx new file mode 100644 index 0000000000..3816df8558 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/ceph-fs.tsx @@ -0,0 +1,46 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { secretsApi } from "../../../../../../common/k8s-api/endpoints"; +import { DrawerItem } from "../../../../drawer"; +import { LocalRef, VolumeVariantComponent } from "../variant-helpers"; + +export const CephFs: VolumeVariantComponent<"cephfs"> = ( + ({ pod, variant: { monitors, path = "/", user = "admin", secretFile = "/etc/ceph/user.secret", secretRef, readOnly }}) => ( + <> + +
    + {monitors.map(monitor =>
  • {monitor}
  • )} +
+
+ + {path} + + + {user} + + { + secretRef + ? ( + + ) + : ( + + {secretFile} + + ) + } + + {readOnly.toString()} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/cinder.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/cinder.tsx new file mode 100644 index 0000000000..366438e0d8 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/cinder.tsx @@ -0,0 +1,21 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const Cinder: VolumeVariantComponent<"cinder"> = ( + ({ variant: { volumeID, fsType = "ext4" }}) => ( + <> + + {volumeID} + + + {fsType} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/config-map.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/config-map.tsx new file mode 100644 index 0000000000..9494a89e39 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/config-map.tsx @@ -0,0 +1,19 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { configMapApi } from "../../../../../../common/k8s-api/endpoints"; +import { LocalRef, VolumeVariantComponent } from "../variant-helpers"; + +export const ConfigMap: VolumeVariantComponent<"configMap"> = ( + ({ pod, variant: { name }}) => ( + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/container-storage-interface.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/container-storage-interface.tsx new file mode 100644 index 0000000000..f60f6c2023 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/container-storage-interface.tsx @@ -0,0 +1,67 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { secretsApi } from "../../../../../../common/k8s-api/endpoints"; +import { DrawerItem } from "../../../../drawer"; +import { LocalRef, VolumeVariantComponent } from "../variant-helpers"; + +export const ContainerStorageInterface: VolumeVariantComponent<"csi"> = ({ + pod, + variant: { + driver, + readOnly = false, + fsType = "ext4", + volumeAttributes = {}, + nodePublishSecretRef, + controllerPublishSecretRef, + nodeStageSecretRef, + controllerExpandSecretRef, + }, +}) => ( + <> + + {driver} + + + {readOnly.toString()} + + + {fsType} + + + + + + { + Object.entries(volumeAttributes) + .map(([key, value]) => ( + + {value} + + )) + } + +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/downward-api.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/downward-api.tsx new file mode 100644 index 0000000000..a2728e11ce --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/downward-api.tsx @@ -0,0 +1,20 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const DownwardApi: VolumeVariantComponent<"downwardAPI"> = ( + ({ variant: { items }}) => ( + <> + +
    + {items.map(item =>
  • {item.path}
  • )} +
+
+ + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/empty-dir.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/empty-dir.tsx new file mode 100644 index 0000000000..01052ebf64 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/empty-dir.tsx @@ -0,0 +1,20 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const EmptyDir: VolumeVariantComponent<"emptyDir"> = ( + ({ variant: { medium, sizeLimit }}) => ( + <> + + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/ephemeral.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/ephemeral.tsx new file mode 100644 index 0000000000..0ec5878c4f --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/ephemeral.tsx @@ -0,0 +1,29 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { dump } from "js-yaml"; +import React from "react"; +import { DrawerItem, DrawerItemLabels } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const Ephemeral: VolumeVariantComponent<"ephemeral"> = ( + ({ pod, volumeName, variant: { volumeClaimTemplate: { metadata, spec }}}) => ( + <> + + {pod.getName()}-{volumeName} + + + + + {dump(spec)} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/fiber-channel.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/fiber-channel.tsx new file mode 100644 index 0000000000..684c4f1f32 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/fiber-channel.tsx @@ -0,0 +1,29 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const FiberChannel: VolumeVariantComponent<"fc"> = ( + ({ variant: { targetWWNs, lun, fsType = "ext4", readOnly = false }}) => ( + <> + +
    + {targetWWNs.map(targetWWN =>
  • {targetWWN}
  • )} +
+
+ + {lun.toString()} + + + {fsType} + + + {readOnly.toString()} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/flex-volume.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/flex-volume.tsx new file mode 100644 index 0000000000..07f68c3da4 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/flex-volume.tsx @@ -0,0 +1,39 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { secretsApi } from "../../../../../../common/k8s-api/endpoints"; +import { DrawerItem } from "../../../../drawer"; +import { LocalRef, VolumeVariantComponent } from "../variant-helpers"; + +export const FlexVolume: VolumeVariantComponent<"flexVolume"> = ( + ({ pod, variant: { driver, fsType, secretRef, readOnly = false, options }}) => ( + <> + + {driver} + + + {fsType || "-- system default --"} + + + + {readOnly.toString()} + + { + ...Object.entries(options) + .map(([key, value]) => ( + + {value} + + )) + } + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/flocker.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/flocker.tsx new file mode 100644 index 0000000000..d4edefcba2 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/flocker.tsx @@ -0,0 +1,18 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const Flocker: VolumeVariantComponent<"flocker"> = ( + ({ variant: { datasetName }}) => ( + <> + + {datasetName} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/gce-persistent-disk.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/gce-persistent-disk.tsx new file mode 100644 index 0000000000..7c15b53109 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/gce-persistent-disk.tsx @@ -0,0 +1,21 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const GcePersistentDisk: VolumeVariantComponent<"gcePersistentDisk"> = ( + ({ variant: { pdName, fsType = "ext4" }}) => ( + <> + + {pdName} + + + {fsType} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/git-repo.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/git-repo.tsx new file mode 100644 index 0000000000..23e6421210 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/git-repo.tsx @@ -0,0 +1,21 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const GitRepo: VolumeVariantComponent<"gitRepo"> = ( + ({ variant: { repository, revision }}) => ( + <> + + {repository} + + + {revision} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/gluster-fs.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/gluster-fs.tsx new file mode 100644 index 0000000000..b3937b7610 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/gluster-fs.tsx @@ -0,0 +1,24 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const GlusterFs: VolumeVariantComponent<"glusterfs"> = ( + ({ variant: { endpoints, path, readOnly = false }}) => ( + <> + + {endpoints} + + + {path} + + + {readOnly.toString()} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/host-path.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/host-path.tsx new file mode 100644 index 0000000000..5b80431733 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/host-path.tsx @@ -0,0 +1,21 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const HostPath: VolumeVariantComponent<"hostPath"> = ( + ({ variant: { path, type }}) => ( + <> + + {path} + + + {type || "-- none --"} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/i-scsi.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/i-scsi.tsx new file mode 100644 index 0000000000..1146752061 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/i-scsi.tsx @@ -0,0 +1,45 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const IScsi: VolumeVariantComponent<"iscsi"> = ( + ({ variant: { targetPortal, iqn, lun, fsType = "ext4", readOnly = false, chapAuthDiscovery, chapAuthSession, secretRef }}) => ( + <> + + {targetPortal} + + + {iqn} + + + {lun.toString()} + + + {fsType} + + + {readOnly.toString()} + + {chapAuthDiscovery && ( + + {chapAuthDiscovery.toString()} + + )} + {chapAuthSession && ( + + {chapAuthSession.toString()} + + )} + { secretRef && ( + + {secretRef.name} + + )} + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/local.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/local.tsx new file mode 100644 index 0000000000..a4e087ae2c --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/local.tsx @@ -0,0 +1,18 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const Local: VolumeVariantComponent<"local"> = ( + ({ variant: { path }}) => ( + <> + + {path} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/network-fs.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/network-fs.tsx new file mode 100644 index 0000000000..d40f2eaa08 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/network-fs.tsx @@ -0,0 +1,24 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const NetworkFs: VolumeVariantComponent<"nfs"> = ( + ({ variant: { server, path, readOnly = false }}) => ( + <> + + {server} + + + {path} + + + {readOnly.toString()} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/persistent-volume-claim.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/persistent-volume-claim.tsx new file mode 100644 index 0000000000..d2aeda160c --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/persistent-volume-claim.tsx @@ -0,0 +1,19 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { pvcApi } from "../../../../../../common/k8s-api/endpoints"; +import { LocalRef, VolumeVariantComponent } from "../variant-helpers"; + +export const PersistentVolumeClaim: VolumeVariantComponent<"persistentVolumeClaim"> = ( + ({ pod, variant: { claimName }}) => ( + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/photon-persistent-disk.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/photon-persistent-disk.tsx new file mode 100644 index 0000000000..457da2f62b --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/photon-persistent-disk.tsx @@ -0,0 +1,21 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const PhotonPersistentDisk: VolumeVariantComponent<"photonPersistentDisk"> = ( + ({ variant: { pdID, fsType = "ext4" }}) => ( + <> + + {pdID} + + + {fsType} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/portworx-volume.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/portworx-volume.tsx new file mode 100644 index 0000000000..103be78acf --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/portworx-volume.tsx @@ -0,0 +1,24 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const PortworxVolume: VolumeVariantComponent<"portworxVolume"> = ( + ({ variant: { volumeID, fsType = "ext4", readOnly = false }}) => ( + <> + + {volumeID} + + + {fsType} + + + {readOnly.toString()} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/projected.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/projected.tsx new file mode 100644 index 0000000000..9a8aa0984c --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/projected.tsx @@ -0,0 +1,82 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem, DrawerTitle } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const Projected: VolumeVariantComponent<"projected"> = ( + ({ variant: { sources, defaultMode }}) => ( + <> + + 0o{defaultMode.toString(8)} + + + { + sources.map(({ secret, downwardAPI, configMap, serviceAccountToken }, index) => ( + + {secret && ( + <> + Secret + + {secret.name} + + {secret.items && ( + +
    + {secret.items.map(({ key }) =>
  • {key}
  • )} +
+
+ )} + + )} + {downwardAPI && ( + <> + Downward API + {downwardAPI.items && ( + +
    + {downwardAPI.items.map(({ path }) =>
  • {path}
  • )} +
+
+ )} + + )} + {configMap && ( + <> + Config Map + + {configMap.name} + + {configMap.items && ( + +
    + {configMap.items.map(({ path }) =>
  • {path}
  • )} +
+
+ )} + + )} + {serviceAccountToken && ( + <> + Service Account Token + + + + {serviceAccountToken.path} + + + )} +
+ )) + } +
+ + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/quobyte.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/quobyte.tsx new file mode 100644 index 0000000000..a315f254e8 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/quobyte.tsx @@ -0,0 +1,33 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const Quobyte: VolumeVariantComponent<"quobyte"> = ( + ({ variant: { registry, volume, readOnly = false, user = "serviceaccount", group, tenant }}) => ( + <> + + {registry} + + + {volume} + + + {readOnly.toString()} + + + {user} + + + {group ?? "-- no group --"} + + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/rados-block-device.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/rados-block-device.tsx new file mode 100644 index 0000000000..172089858d --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/rados-block-device.tsx @@ -0,0 +1,52 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { secretsApi } from "../../../../../../common/k8s-api/endpoints"; +import { DrawerItem } from "../../../../drawer"; +import { LocalRef, VolumeVariantComponent } from "../variant-helpers"; + +export const RadosBlockDevice: VolumeVariantComponent<"rbd"> = ( + ({ pod, variant: { monitors, image, fsType = "ext4", pool = "rbd", user = "admin", keyring = "/etc/ceph/keyright", secretRef, readOnly = false }}) => ( + <> + +
    + {monitors.map(monitor =>
  • {monitor}
  • )} +
+
+ + {image} + + + {fsType} + + + {pool} + + + {user} + + { + secretRef + ? ( + + ) + : ( + + {keyring} + + ) + } + + {readOnly.toString()} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/scale-io.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/scale-io.tsx new file mode 100644 index 0000000000..506346173b --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/scale-io.tsx @@ -0,0 +1,52 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { secretsApi } from "../../../../../../common/k8s-api/endpoints"; +import { DrawerItem } from "../../../../drawer"; +import { LocalRef, VolumeVariantComponent } from "../variant-helpers"; + +export const ScaleIo: VolumeVariantComponent<"scaleIO"> = ( + ({ pod, variant: { gateway, system, secretRef, sslEnabled = false, protectionDomain, storagePool, storageMode = "ThinProvisioned", volumeName, fsType = "xfs", readOnly = false }}) => ( + <> + + {gateway} + + + {system} + + + + {sslEnabled.toString()} + + + {sslEnabled.toString()} + + + + + + {volumeName} + + + {fsType} + + + {readOnly.toString()} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/secret.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/secret.tsx new file mode 100644 index 0000000000..606d9a13aa --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/secret.tsx @@ -0,0 +1,33 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { secretsApi } from "../../../../../../common/k8s-api/endpoints"; +import { DrawerItem } from "../../../../drawer"; +import { LocalRef, VolumeVariantComponent } from "../variant-helpers"; + +export const Secret: VolumeVariantComponent<"secret"> = ( + ({ pod, variant: { secretName, items = [], defaultMode = 0o644, optional = false }}) => ( + <> + + + + 0o{defaultMode.toString(8)} + + + {optional.toString()} + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/storage-os.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/storage-os.tsx new file mode 100644 index 0000000000..921fd8c26e --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/storage-os.tsx @@ -0,0 +1,38 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { secretsApi } from "../../../../../../common/k8s-api/endpoints"; +import { DrawerItem } from "../../../../drawer"; +import { LocalRef, VolumeVariantComponent } from "../variant-helpers"; + +export const StorageOs: VolumeVariantComponent<"storageos"> = ( + ({ pod, variant: { volumeName, volumeNamespace, fsType = "ext4", readOnly = false, secretRef }}) => ( + <> + + {volumeName} + + + + {fsType} + + + {readOnly.toString()} + + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/variants/vsphere-volume.tsx b/src/renderer/components/+workloads-pods/details/volumes/variants/vsphere-volume.tsx new file mode 100644 index 0000000000..eb97917e91 --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/variants/vsphere-volume.tsx @@ -0,0 +1,27 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import React from "react"; +import { DrawerItem } from "../../../../drawer"; +import type { VolumeVariantComponent } from "../variant-helpers"; + +export const VsphereVolume: VolumeVariantComponent<"vsphereVolume"> = ( + ({ variant: { volumePath, fsType = "ext4", storagePolicyName, storagePolicyID }}) => ( + <> + + {volumePath} + + + {fsType} + + + + + ) +); diff --git a/src/renderer/components/+workloads-pods/details/volumes/view.tsx b/src/renderer/components/+workloads-pods/details/volumes/view.tsx new file mode 100644 index 0000000000..600e642f7c --- /dev/null +++ b/src/renderer/components/+workloads-pods/details/volumes/view.tsx @@ -0,0 +1,38 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import { observer } from "mobx-react"; +import React from "react"; +import type { Pod } from "../../../../../common/k8s-api/endpoints"; +import { DrawerTitle } from "../../../drawer"; +import { Icon } from "../../../icon"; +import { VolumeVarient } from "./variant"; + +export interface PodVolumesProps { + pod: Pod; +} + +export const PodVolumes = observer(({ pod }: PodVolumesProps) => { + const volumes = pod.getVolumes() ?? []; + + if (volumes.length === 0) { + return null; + } + + return ( + <> + Volumes + {volumes.map(volume => ( +
+
+ + {volume.name} +
+ +
+ ))} + + ); +}); diff --git a/src/renderer/components/+workloads-pods/pod-details-volumes.tsx b/src/renderer/components/+workloads-pods/pod-details-volumes.tsx deleted file mode 100644 index fd1cafc15c..0000000000 --- a/src/renderer/components/+workloads-pods/pod-details-volumes.tsx +++ /dev/null @@ -1,658 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ - -import jsyaml from "js-yaml"; -import { observer } from "mobx-react"; -import React from "react"; -import { Link } from "react-router-dom"; -import type { RequireAllOrNone } from "type-fest"; -import { configMapApi, Pod, PodVolume, PodVolumeKind, PodVolumeVariants, pvcApi, SecretReference, secretsApi } from "../../../common/k8s-api/endpoints"; -import type { KubeApi } from "../../../common/k8s-api/kube-api"; -import type { KubeObject, LocalObjectReference } from "../../../common/k8s-api/kube-object"; -import { entries } from "../../utils"; -import { DrawerItem, DrawerItemLabels, DrawerTitle } from "../drawer"; -import { Icon } from "../icon"; -import { getDetailsUrl } from "../kube-detail-params"; - -/** - * Additional parameters for each volume variant - */ -export interface VariantOptions { - pod: Pod; - volumeName: string; -} - -function renderLocalRef(pod: Pod, title: string, ref: LocalObjectReference | SecretReference, typeApi: KubeApi) { - return ( - - - {ref.name} - - - ); -} - -/** - * - */ -type PodVolumeVariantRenderers = { - [Key in keyof PodVolumeVariants]: (variant: PodVolumeVariants[Key], opts: VariantOptions) => React.ReactChild; -}; - -const volumeRenderers: PodVolumeVariantRenderers = { - awsElasticBlockStore: ({ volumeID, fsType = "ext4" }) => ( - <> - - {volumeID} - - - {fsType} - - - ), - azureDisk: ({ diskName, diskURI, kind = "Shared", cachingMode = "None", fsType = "ext4", readonly = false }) => ( - <> - - {diskName} - - - {diskURI} - - - {kind} - - - {cachingMode} - - - {fsType} - - - {readonly.toString()} - - - ), - azureFile: ({ readOnly = false, secretName, shareName, secretNamespace = "default" }) => ( - <> - - {secretName} - - - {shareName} - - - {secretNamespace} - - - {readOnly.toString()} - - - ), - ephemeral: ({ volumeClaimTemplate: { metadata, spec }}, { pod, volumeName }) => ( - <> - - {pod.getName()}-{volumeName} - - - - - {jsyaml.dump(spec)} - - - ), - emptyDir: ({ medium, sizeLimit }) => ( - <> - - - - ), - cephfs: ({ monitors, path = "/", user = "admin", secretFile = "/etc/ceph/user.secret", secretRef, readOnly }, { pod }) => ( - <> - -
    - {monitors.map(monitor =>
  • {monitor}
  • )} -
-
- - {path} - - - {user} - - { - secretRef - ? renderLocalRef(pod, "Secret", secretRef, secretsApi) - : ( - - {secretFile} - - ) - } - - {readOnly.toString()} - - - ), - cinder: ({ volumeID, fsType = "ext4" }) => ( - <> - - {volumeID} - - - {fsType} - - - ), - configMap: ({ name }, { pod }) => renderLocalRef(pod, "Name", { name }, configMapApi), - downwardAPI: ({ items }) => ( - <> - -
    - {items.map(item =>
  • {item.path}
  • )} -
-
- - ), - fc: ({ targetWWNs, lun, fsType = "ext4", readOnly = false }) => ( - <> - -
    - {targetWWNs.map(targetWWN =>
  • {targetWWN}
  • )} -
-
- - {lun.toString()} - - - {fsType} - - - {readOnly.toString()} - - - ), - flexVolume: ({ driver, fsType, secretRef, readOnly = false, options }, { pod }) => ( - <> - - {driver} - - - {fsType || "-- system default --"} - - {secretRef && renderLocalRef(pod, "Secret", secretRef, secretsApi)} - - {readOnly.toString()} - - { - ...Object.entries(options) - .map(([key, value]) => ( - - {value} - - )) - } - - ), - flocker: ({ datasetName }) => ( - <> - - {datasetName} - - - ), - gcePersistentDisk: ({ pdName, fsType = "ext4" }) => ( - <> - - {pdName} - - - {fsType} - - - ), - gitRepo: ({ repository, revision }) => ( - <> - - {repository} - - - {revision} - - - ), - glusterfs: ({ endpoints, path, readOnly = false }) => ( - <> - - {endpoints} - - - {path} - - - {readOnly.toString()} - - - ), - hostPath: ({ path, type }) => ( - <> - - {path} - - - {type || "-- none --"} - - - ), - iscsi: ({ targetPortal, iqn, lun, fsType = "ext4", readOnly = false, chapAuthDiscovery, chapAuthSession, secretRef }) => ( - <> - - {targetPortal} - - - {iqn} - - - {lun.toString()} - - - {fsType} - - - {readOnly.toString()} - - {chapAuthDiscovery && ( - - {chapAuthDiscovery.toString()} - - )} - {chapAuthSession && ( - - {chapAuthSession.toString()} - - )} - { secretRef && ( - - {secretRef.name} - - )} - - ), - local: ({ path }) => ( - <> - - {path} - - - ), - nfs: ({ server, path, readOnly = false }) => ( - <> - - {server} - - - {path} - - - {readOnly.toString()} - - - ), - persistentVolumeClaim: ({ claimName }, { pod }) => renderLocalRef(pod, "Name", { name: claimName }, pvcApi), - photonPersistentDisk: ({ pdID, fsType = "ext4" }) => ( - <> - - {pdID} - - - {fsType} - - - ), - portworxVolume: ({ volumeID, fsType = "ext4", readOnly = false }) => ( - <> - - {volumeID} - - - {fsType} - - - {readOnly.toString()} - - - ), - projected: ({ sources, defaultMode }) => ( - <> - - 0o{defaultMode.toString(8)} - - - { - sources.map(({ secret, downwardAPI, configMap, serviceAccountToken }, index) => ( - - {secret && ( - <> - Secret - - {secret.name} - - {secret.items && ( - -
    - {secret.items.map(({ key }) =>
  • {key}
  • )} -
-
- )} - - )} - {downwardAPI && ( - <> - Downward API - {downwardAPI.items && ( - -
    - {downwardAPI.items.map(({ path }) =>
  • {path}
  • )} -
-
- )} - - )} - {configMap && ( - <> - Config Map - - {configMap.name} - - {configMap.items && ( - -
    - {configMap.items.map(({ path }) =>
  • {path}
  • )} -
-
- )} - - )} - {serviceAccountToken && ( - <> - Service Account Token - - - - {serviceAccountToken.path} - - - )} -
- )) - } -
- - ), - quobyte: ({ registry, volume, readOnly = false, user = "serviceaccount", group, tenant }) => ( - <> - - {registry} - - - {volume} - - - {readOnly.toString()} - - - {user} - - - {group ?? "-- no group --"} - - - - ), - rbd: ({ monitors, image, fsType = "ext4", pool = "rbd", user = "admin", keyring = "/etc/ceph/keyright", secretRef, readOnly = false }, { pod }) => ( - <> - -
    - {monitors.map(monitor =>
  • {monitor}
  • )} -
-
- - {image} - - - {fsType} - - - {pool} - - - {user} - - { - secretRef - ? renderLocalRef(pod, "Authentication Secret", secretRef, secretsApi) - : ( - - {keyring} - - ) - } - - {readOnly.toString()} - - - ), - scaleIO: ({ gateway, system, secretRef, sslEnabled = false, protectionDomain, storagePool, storageMode = "ThinProvisioned", volumeName, fsType = "xfs", readOnly = false }, { pod }) => ( - <> - - {gateway} - - - {system} - - {renderLocalRef(pod, "Name", secretRef, secretsApi)} - - {sslEnabled.toString()} - - - {sslEnabled.toString()} - - - - - - {volumeName} - - - {fsType} - - - {readOnly.toString()} - - - ), - secret: ({ secretName, items = [], defaultMode = 0o644, optional = false }, { pod }) => ( - <> - {renderLocalRef(pod, "Name", { name: secretName }, secretsApi)} - - - 0o{defaultMode.toString(8)} - - - {optional.toString()} - - - ), - storageos: ({ volumeName, volumeNamespace, fsType = "ext4", readOnly = false, secretRef }, { pod }) => ( - <> - - {volumeName} - - - - {fsType} - - - {readOnly.toString()} - - {secretRef && renderLocalRef(pod, "Secret", secretRef, secretsApi)} - - ), - vsphereVolume: ({ volumePath, fsType = "ext4", storagePolicyName, storagePolicyID }) => ( - <> - - {volumePath} - - - {fsType} - - - - - ), - csi: ({ driver, readOnly = false, fsType = "ext4", volumeAttributes = {}, nodePublishSecretRef, controllerPublishSecretRef, nodeStageSecretRef, controllerExpandSecretRef }, { pod }) => ( - <> - - {driver} - - - {readOnly.toString()} - - - {fsType} - - {controllerPublishSecretRef && renderLocalRef(pod, "Controller Publish Secret", controllerPublishSecretRef, secretsApi)} - {controllerExpandSecretRef && renderLocalRef(pod, "Controller Expand Secret", controllerExpandSecretRef, secretsApi)} - {nodePublishSecretRef && renderLocalRef(pod, "Node Publish Secret", nodePublishSecretRef, secretsApi)} - {nodeStageSecretRef && renderLocalRef(pod, "Node Stage Secret", nodeStageSecretRef, secretsApi)} - { - ...Object.entries(volumeAttributes) - .map(([key, value]) => ( - - {value} - - )) - } - - ), -}; - -export interface PodVolumesProps { - pod: Pod; -} - -const deprecatedVolumeTypes = new Set([ - "flocker", - "gitRepo", - "quobyte", - "storageos", -]); - -interface VolumeRendererPair { - kind: PodVolumeKind; - render: () => React.ReactChild; -} - -function getVolumeType(pod: Pod, volume: PodVolume): RequireAllOrNone { - for (const [kind, varient] of entries(volume)) { - if (kind === "name") { - continue; // This key is not a kind field - } - - if (!varient || typeof varient !== "object") { - continue; - } - - return { - kind, - render: () => volumeRenderers[kind](varient as never, { pod, volumeName: volume.name }), - }; - } - - return {}; -} - -export const PodVolumes = observer(({ pod }: PodVolumesProps) => { - if (!pod) { - return null; - } - - const renderVolume = (volume: PodVolume) => { - const { kind, render } = getVolumeType(pod, volume); - const isDeprecated = deprecatedVolumeTypes.has(kind); - - console.log(volume, render); - - return ( -
-
- - {volume.name} -
- { - kind - ? ( - <> - - {kind} - {isDeprecated && } - - {render?.()} - - ) - :

Error! Unknown pod volume kind

- } -
- ); - }; - - const volumes = pod.getVolumes(); - - if (volumes.length === 0) { - return null; - } - - return ( - <> - Volumes - {volumes.map(renderVolume)} - - ); -}); diff --git a/src/renderer/components/+workloads-pods/pod-details.tsx b/src/renderer/components/+workloads-pods/pod-details.tsx index 6510fd90ff..857faeefab 100644 --- a/src/renderer/components/+workloads-pods/pod-details.tsx +++ b/src/renderer/components/+workloads-pods/pod-details.tsx @@ -27,7 +27,7 @@ import { getActiveClusterEntity } from "../../api/catalog-entity-registry"; import { ClusterMetricsResourceType } from "../../../common/cluster-types"; import { getDetailsUrl } from "../kube-detail-params"; import logger from "../../../common/logger"; -import { PodVolumes } from "./pod-details-volumes"; +import { PodVolumes } from "./details/volumes/view"; export interface PodDetailsProps extends KubeObjectDetailsProps { } diff --git a/src/renderer/components/drawer/drawer-item.tsx b/src/renderer/components/drawer/drawer-item.tsx index 1e0a50f8e4..1f49ca92e7 100644 --- a/src/renderer/components/drawer/drawer-item.tsx +++ b/src/renderer/components/drawer/drawer-item.tsx @@ -20,12 +20,12 @@ export function DrawerItem({ title, labelsOnly, children, - hidden, + hidden = false, className, renderBoolean, ...elemProps }: DrawerItemProps) { - if (!hidden) { + if (hidden) { return null; }