From 47d1f28da4d25603ee9168705b0c52cbebad8b2f Mon Sep 17 00:00:00 2001 From: PoAn Yang Date: Thu, 18 Apr 2024 09:56:59 +0800 Subject: [PATCH] fix: get storage class name from vmimage status (#94) Signed-off-by: PoAn Yang --- .../virtualmachine/resource_virtualmachine_constructor.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/provider/virtualmachine/resource_virtualmachine_constructor.go b/internal/provider/virtualmachine/resource_virtualmachine_constructor.go index 257b183d..5c80406c 100644 --- a/internal/provider/virtualmachine/resource_virtualmachine_constructor.go +++ b/internal/provider/virtualmachine/resource_virtualmachine_constructor.go @@ -218,8 +218,12 @@ func (c *Constructor) Setup() util.Processors { if err != nil { return err } + vmimage, err := c.Client.HarvesterClient.HarvesterhciV1beta1().VirtualMachineImages(imageNamespace).Get(c.Context, imageName, metav1.GetOptions{}) + if err != nil { + return err + } pvcOption.ImageID = helper.BuildNamespacedName(imageNamespace, imageName) - scName := builder.BuildImageStorageClassName("", imageName) + scName := vmimage.Status.StorageClassName if storageClassName == "" { storageClassName = scName } else if storageClassName != scName {