From 81fe75fae24c7f35f3431d1b7fb30d1b06772f5f Mon Sep 17 00:00:00 2001 From: stoneshi-yunify <70880165+stoneshi-yunify@users.noreply.github.com> Date: Mon, 14 Sep 2020 18:40:07 +0800 Subject: [PATCH] fix: add nil check for storage class name Signed-off-by: stoneshi-yunify <70880165+stoneshi-yunify@users.noreply.github.com> --- pkg/models/resources/v1alpha2/storageclass/storageclasses.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/models/resources/v1alpha2/storageclass/storageclasses.go b/pkg/models/resources/v1alpha2/storageclass/storageclasses.go index fa651e1e4..9c04aa1b3 100644 --- a/pkg/models/resources/v1alpha2/storageclass/storageclasses.go +++ b/pkg/models/resources/v1alpha2/storageclass/storageclasses.go @@ -107,7 +107,7 @@ func (s *storageClassesSearcher) countPersistentVolumeClaims(name string) int { var count int for _, pvc := range pvcs { - if *pvc.Spec.StorageClassName == name || (pvc.Annotations != nil && pvc.Annotations[corev1.BetaStorageClassAnnotation] == name) { + if (pvc.Spec.StorageClassName != nil && *pvc.Spec.StorageClassName == name) || (pvc.Annotations != nil && pvc.Annotations[corev1.BetaStorageClassAnnotation] == name) { count++ } }