-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CNV-23832: Apply boot StorageClass from Template's boot source
Signed-off-by: Aviv Turgeman <[email protected]>
- Loading branch information
Showing
5 changed files
with
75 additions
and
5 deletions.
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
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
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
22 changes: 22 additions & 0 deletions
22
src/views/catalog/templatescatalog/components/TemplatesCatalogDrawer/utils/helpers.ts
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,22 @@ | ||
import { StorageClassModel } from '@kubevirt-ui/kubevirt-api/console'; | ||
import { IoK8sApiStorageV1StorageClassList } from '@kubevirt-ui/kubevirt-api/kubernetes'; | ||
import { V1VirtualMachine } from '@kubevirt-ui/kubevirt-api/kubevirt'; | ||
import { isDefaultStorageClass } from '@kubevirt-utils/components/DiskModal/DiskFormFields/utils/helpers'; | ||
import { getDataVolumeTemplates } from '@kubevirt-utils/resources/vm'; | ||
import { isEmpty } from '@kubevirt-utils/utils/utils'; | ||
import { k8sGet } from '@openshift-console/dynamic-plugin-sdk'; | ||
|
||
export const hasStorageClass = async (vm: V1VirtualMachine) => { | ||
const vmSCExists = getDataVolumeTemplates(vm)?.some( | ||
(dvt) => !!dvt?.spec?.storage?.storageClassName, | ||
); | ||
if (vmSCExists) return true; | ||
|
||
const storageClasses = await k8sGet<IoK8sApiStorageV1StorageClassList>({ | ||
model: StorageClassModel, | ||
}); | ||
|
||
const defaultSC = storageClasses?.items?.find((item) => isDefaultStorageClass(item)); | ||
|
||
return !isEmpty(defaultSC); | ||
}; |
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