Skip to content

Commit

Permalink
Merge pull request #1432 from headlamp-k8s/fix-pvc-without-storage-class
Browse files Browse the repository at this point in the history
fix pvc without storage class
  • Loading branch information
joaquimrocha authored Oct 5, 2023
2 parents 317aea5 + 0f46897 commit 0f09b81
Show file tree
Hide file tree
Showing 4 changed files with 534 additions and 1 deletion.
70 changes: 70 additions & 0 deletions frontend/src/components/storage/ClaimList.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Meta, Story } from '@storybook/react/types-6-0';
import _ from 'lodash';
import PersistentVolumeClaim, {
KubePersistentVolumeClaim,
} from '../../lib/k8s/persistentVolumeClaim';
import { TestContext } from '../../test';
import PVClaimList from './ClaimList';

const basePVC = {
apiVersion: 'v1',
kind: 'PersistentVolumeClaim',
metadata: {
creationTimestamp: '2023-04-27T20:31:27Z',
finalizers: ['kubernetes.io/pvc-protection'],
name: 'my-pvc',
namespace: 'default',
resourceVersion: '1234',
uid: 'abc-1234',
},
spec: {
accessModes: ['ReadWriteOnce'],
resources: {
requests: {
storage: '8Gi',
},
},
storageClassName: 'default',
volumeMode: 'Filesystem',
volumeName: 'pvc-abc-1234',
},
status: {
accessModes: ['ReadWriteOnce'],
capacity: {
storage: '8Gi',
},
phase: 'Bound',
},
};

PersistentVolumeClaim.useList = () => {
const noStorageClassNamePVC = _.cloneDeep(basePVC);
noStorageClassNamePVC.metadata.name = 'no-storage-class-name-pvc';
noStorageClassNamePVC.spec.storageClassName = '';

const objList = [basePVC, noStorageClassNamePVC].map(
pvc => new PersistentVolumeClaim(pvc as KubePersistentVolumeClaim)
);
return [objList, null, () => {}, () => {}] as any;
};

export default {
title: 'Storage/PersistentVolumeClaim',
component: PVClaimList,
argTypes: {},
decorators: [
Story => {
return (
<TestContext>
<Story />
</TestContext>
);
},
],
} as Meta;

const Template: Story = () => {
return <PVClaimList />;
};

export const ListView = Template.bind({});
3 changes: 3 additions & 0 deletions frontend/src/components/storage/ClaimList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export default function VolumeClaimList() {
label: t('Class Name'),
getter: volumeClaim => {
const name = volumeClaim.spec.storageClassName;
if (!name) {
return '';
}
return (
<Link routeName="storageClass" params={{ name }} tooltip>
{name}
Expand Down
Loading

0 comments on commit 0f09b81

Please sign in to comment.