diff --git a/apis/apps/v1alpha1/cluster_types.go b/apis/apps/v1alpha1/cluster_types.go index 338f39b83e2..60d538159a7 100644 --- a/apis/apps/v1alpha1/cluster_types.go +++ b/apis/apps/v1alpha1/cluster_types.go @@ -392,7 +392,7 @@ type PersistentVolumeClaimSpec struct { } // ToV1PersistentVolumeClaimSpec converts to corev1.PersistentVolumeClaimSpec. -func (r PersistentVolumeClaimSpec) ToV1PersistentVolumeClaimSpec() corev1.PersistentVolumeClaimSpec { +func (r *PersistentVolumeClaimSpec) ToV1PersistentVolumeClaimSpec() corev1.PersistentVolumeClaimSpec { return corev1.PersistentVolumeClaimSpec{ AccessModes: r.AccessModes, Resources: r.Resources, @@ -402,10 +402,14 @@ func (r PersistentVolumeClaimSpec) ToV1PersistentVolumeClaimSpec() corev1.Persis // GetStorageClassName returns PersistentVolumeClaimSpec.StorageClassName if a value is assigned; otherwise, // it returns preferSC argument. -func (r PersistentVolumeClaimSpec) GetStorageClassName(preferSC string) *string { +func (r *PersistentVolumeClaimSpec) GetStorageClassName(preferSC string) *string { if r.StorageClassName != nil && *r.StorageClassName != "" { return r.StorageClassName } + + if preferSC == "" { + return nil + } return &preferSC }