Skip to content

Commit

Permalink
Fix nil pointer panic for map(s) inside metadata struct (minio#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
nitisht authored and harshavardhana committed Jul 16, 2019
1 parent cc272b5 commit 493bf3e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/resources/statefulsets/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ func minioMetadata(mi *miniov1beta1.MinIOInstance) metav1.ObjectMeta {
if mi.HasMetadata() {
meta = *mi.Spec.Metadata
}
// Initialize empty fields
if meta.Labels == nil {
meta.Labels = make(map[string]string)
}
if meta.Annotations == nil {
meta.Annotations = make(map[string]string)
}
// Add the additional label used by StatefulSet spec
podLabelKey, podLabelValue := minioPodLabels(mi)
meta.Labels[podLabelKey] = podLabelValue
Expand Down

0 comments on commit 493bf3e

Please sign in to comment.