Skip to content

Commit 39d22d1

Browse files
committed
Moving code to helper.go
1 parent c67f3bb commit 39d22d1

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

pkg/apis/operator.min.io/v1/helper.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,22 @@ func (mi *MinIOInstance) CreateMCSUser(minioSecret, mcsSecret map[string][]byte)
415415
return nil
416416
}
417417

418+
// Validate returns an error if any configuration of the MinIO instance is invalid
419+
func (in *MinIOInstance) Validate() error {
420+
// Make sure the storage request is not 0
421+
if in.Spec.VolumeClaimTemplate.Spec.Resources.Requests.Storage().Value() == 0 {
422+
return errors.New("cannot use volume size 0")
423+
}
424+
// Make sure the replicas are not 0 on any zone
425+
for _, z := range in.Spec.Zones {
426+
if z.Servers == 0 {
427+
return fmt.Errorf("zone '%s' cannot have 0 servers", z.Name)
428+
}
429+
}
430+
431+
return nil
432+
}
433+
418434
// Set up admin client to use self certificates
419435
func setUpInsecureTLS(api *madmin.AdminClient) *madmin.AdminClient {
420436
// Keep TLS config.

pkg/apis/operator.min.io/v1/types.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
package v1
1919

2020
import (
21-
"errors"
22-
"fmt"
23-
2421
appsv1 "k8s.io/api/apps/v1"
2522
corev1 "k8s.io/api/core/v1"
2623
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -42,22 +39,6 @@ type MinIOInstance struct {
4239
Status MinIOInstanceStatus `json:"status"`
4340
}
4441

45-
// Validate returns an error if any configuration of the MinIO instance is invalid
46-
func (in *MinIOInstance) Validate() error {
47-
// Make sure the storage request is not 0
48-
if in.Spec.VolumeClaimTemplate.Spec.Resources.Requests.Storage().Value() == 0 {
49-
return errors.New("cannot use volume size 0")
50-
}
51-
// Make sure the replicas are not 0 on any zone
52-
for _, z := range in.Spec.Zones {
53-
if z.Servers == 0 {
54-
return fmt.Errorf("zone '%s' cannot have 0 servers", z.Name)
55-
}
56-
}
57-
58-
return nil
59-
}
60-
6142
// MinIOInstanceScheduler is the spec for a MinIOInstance scheduler
6243
type MinIOInstanceScheduler struct {
6344
// SchedulerName defines the name of scheduler to be used to schedule MinIOInstance pods

0 commit comments

Comments
 (0)