/** * 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 { DrawerItem } from "../../../drawer"; import { Icon } from "../../../icon"; 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 deprecatedVolumeTypes = new Set([ "flocker", "gitRepo", "quobyte", "storageos", ]); interface VolumeVariantProps { pod: Pod; volume: PodVolume; } interface VolumeVariantRender { kind: PodVolumeKind; element: JSX.Element; } function renderVolumeVariant({ pod, volume }: VolumeVariantProps): VolumeVariantRender | null { if (volume.awsElasticBlockStore) { return { kind: "awsElasticBlockStore", element: , }; } if (volume.azureDisk) { return { kind: "azureDisk", element: , }; } if (volume.azureFile) { return { kind: "azureFile", element: , }; } if (volume.cephfs) { return { kind: "cephfs", element: , }; } if (volume.cinder) { return { kind: "cinder", element: , }; } if (volume.configMap) { return { kind: "configMap", element: , }; } if (volume.csi) { return { kind: "csi", element: , }; } if (volume.downwardAPI) { return { kind: "downwardAPI", element: , }; } if (volume.emptyDir) { return { kind: "emptyDir", element: , }; } if (volume.ephemeral) { return { kind: "ephemeral", element: , }; } if (volume.fc) { return { kind: "fc", element: , }; } if (volume.flexVolume) { return { kind: "flexVolume", element: , }; } if (volume.flocker) { return { kind: "flocker", element: , }; } if (volume.gcePersistentDisk) { return { kind: "gcePersistentDisk", element: , }; } if (volume.gitRepo) { return { kind: "gitRepo", element: , }; } if (volume.glusterfs) { return { kind: "glusterfs", element: , }; } if (volume.hostPath) { return { kind: "hostPath", element: , }; } if (volume.iscsi) { return { kind: "iscsi", element: , }; } if (volume.local) { return { kind: "local", element: , }; } if (volume.nfs) { return { kind: "nfs", element: , }; } if (volume.persistentVolumeClaim) { return { kind: "persistentVolumeClaim", element: , }; } if (volume.photonPersistentDisk) { return { kind: "photonPersistentDisk", element: , }; } if (volume.portworxVolume) { return { kind: "portworxVolume", element: , }; } if (volume.projected) { return { kind: "projected", element: , }; } if (volume.quobyte) { return { kind: "quobyte", element: , }; } if (volume.rbd) { return { kind: "rbd", element: , }; } if (volume.scaleIO) { return { kind: "scaleIO", element: , }; } if (volume.secret) { return { kind: "secret", element: , }; } if (volume.storageos) { return { kind: "storageos", element: , }; } if (volume.vsphereVolume) { return { kind: "vsphereVolume", element: , }; } return null; } export function VolumeVariant(props: VolumeVariantProps) { const result = renderVolumeVariant(props); if (!result) { return

Error! Unknown pod volume kind

; } const { kind, element } = result; const isDeprecated = deprecatedVolumeTypes.has(kind); return ( <> {kind} {isDeprecated && } {element} ); }