Skip to content

Commit

Permalink
Add nil checks for zones and credsecret to prevent crashing (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
nitisht authored Jul 13, 2020
1 parent 04cea51 commit cefe18f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/apis/operator.min.io/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ func (mi *MinIOInstance) Validate() error {
if mi.Spec.VolumeClaimTemplate.Spec.Resources.Requests.Storage().Value() <= 0 {
return errors.New("volume size must be greater than 0")
}
if mi.Spec.Zones == nil {
return errors.New("please provide a zone for MinIOInstance")
}
if mi.Spec.CredsSecret == nil {
return errors.New("please set credsSecret secret with credentials for MinIOInstance")
}
// Make sure the replicas are not 0 on any zone
for _, z := range mi.Spec.Zones {
if z.Servers == 0 {
Expand Down

0 comments on commit cefe18f

Please sign in to comment.