Skip to content

Commit

Permalink
Merge pull request grafana#651 from MasayaAoyama/feature/use-default-…
Browse files Browse the repository at this point in the history
…storage-class-v4

fix: use default storage class when class is not defined
  • Loading branch information
pb82 authored Dec 14, 2021
2 parents 6b588bb + e1837f7 commit f8d2237
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit f8d2237

Please sign in to comment.