-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1432 from headlamp-k8s/fix-pvc-without-storage-class
fix pvc without storage class
- Loading branch information
Showing
4 changed files
with
534 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.