less verbose

Signed-off-by: Howard Lau <howardlau1999@hotmail.com>
This commit is contained in:
Howard Lau 2020-11-01 08:50:31 +00:00
parent 9d134da582
commit 6437abce16
No known key found for this signature in database
GPG Key ID: 5CCC55849E3CF8E2
1 changed files with 6 additions and 6 deletions

View File

@ -17,12 +17,12 @@ limitations under the License.
package v1 package v1
import ( import (
"fmt" "errors"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/errors" utilerrors "k8s.io/apimachinery/pkg/util/errors"
ctrl "sigs.k8s.io/controller-runtime" ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log" logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook"
@ -62,18 +62,18 @@ func (r *Seaweed) ValidateCreate() error {
// TODO(user): fill in your validation logic upon object creation. // TODO(user): fill in your validation logic upon object creation.
if r.Spec.Master == nil { if r.Spec.Master == nil {
errs = append(errs, fmt.Errorf("seaweed[%s/%s] must have master spec", r.Namespace, r.Name)) errs = append(errs, errors.New("missing master spec"))
} }
if r.Spec.Volume == nil { if r.Spec.Volume == nil {
errs = append(errs, fmt.Errorf("seaweed[%s/%s] must have volume spec", r.Namespace, r.Name)) errs = append(errs, errors.New("missing volume spec"))
} else { } else {
if r.Spec.Volume.Requests[corev1.ResourceStorage].Equal(resource.MustParse("0")) { if r.Spec.Volume.Requests[corev1.ResourceStorage].Equal(resource.MustParse("0")) {
errs = append(errs, fmt.Errorf("seaweed[%s/%s] volume storage request cannot be zero", r.Namespace, r.Name)) errs = append(errs, errors.New("volume storage request cannot be zero"))
} }
} }
return errors.NewAggregate(errs) return utilerrors.NewAggregate(errs)
} }
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type