Skip to content

fix: use default storage class when class is not defined #651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion controllers/model/grafanaDataPvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ func getPVCAnnotations(cr *v1alpha1.Grafana, existing map[string]string) map[str
return MergeAnnotations(cr.Spec.DataStorage.Annotations, existing)
}

func getStorageClass(cr *v1alpha1.Grafana) *string {
if cr.Spec.DataStorage == nil || cr.Spec.DataStorage.Class == "" {
return nil
}

return &cr.Spec.DataStorage.Class
}

func getPVCSpec(cr *v1alpha1.Grafana) corev1.PersistentVolumeClaimSpec {
return corev1.PersistentVolumeClaimSpec{
AccessModes: cr.Spec.DataStorage.AccessModes,
Expand All @@ -32,7 +40,7 @@ func getPVCSpec(cr *v1alpha1.Grafana) corev1.PersistentVolumeClaimSpec {
corev1.ResourceStorage: cr.Spec.DataStorage.Size,
},
},
StorageClassName: &cr.Spec.DataStorage.Class,
StorageClassName: getStorageClass(cr),
}
}

Expand Down