From 6437abce16e539a095ceb8bf077b2a7fb2129c69 Mon Sep 17 00:00:00 2001 From: Howard Lau Date: Sun, 1 Nov 2020 08:50:31 +0000 Subject: [PATCH] less verbose Signed-off-by: Howard Lau --- api/v1/seaweed_webhook.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/v1/seaweed_webhook.go b/api/v1/seaweed_webhook.go index 9bd9130..56b6aed 100644 --- a/api/v1/seaweed_webhook.go +++ b/api/v1/seaweed_webhook.go @@ -17,12 +17,12 @@ limitations under the License. package v1 import ( - "fmt" + "errors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/errors" + utilerrors "k8s.io/apimachinery/pkg/util/errors" ctrl "sigs.k8s.io/controller-runtime" logf "sigs.k8s.io/controller-runtime/pkg/log" "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. 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 { - 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 { 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