Use errdefs package
This commit is contained in:
@@ -18,8 +18,7 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/cpuguy83/strongerrors"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
||||
"github.com/virtual-kubelet/virtual-kubelet/version"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
@@ -100,7 +99,7 @@ func getTaint(c Opts) (*corev1.Taint, error) {
|
||||
case "PreferNoSchedule":
|
||||
effect = corev1.TaintEffectPreferNoSchedule
|
||||
default:
|
||||
return nil, strongerrors.InvalidArgument(errors.Errorf("taint effect %q is not supported", effectEnv))
|
||||
return nil, errdefs.InvalidInputf("taint effect %q is not supported", effectEnv)
|
||||
}
|
||||
|
||||
return &corev1.Taint{
|
||||
|
||||
@@ -20,9 +20,9 @@ import (
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/cpuguy83/strongerrors"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||
"github.com/virtual-kubelet/virtual-kubelet/log"
|
||||
"github.com/virtual-kubelet/virtual-kubelet/manager"
|
||||
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
||||
@@ -64,11 +64,11 @@ func runRootCommand(ctx context.Context, c Opts) error {
|
||||
defer cancel()
|
||||
|
||||
if ok := providers.ValidOperatingSystems[c.OperatingSystem]; !ok {
|
||||
return strongerrors.InvalidArgument(errors.Errorf("operating system %q is not supported", c.OperatingSystem))
|
||||
return errdefs.InvalidInputf("operating system %q is not supported", c.OperatingSystem)
|
||||
}
|
||||
|
||||
if c.PodSyncWorkers == 0 {
|
||||
return strongerrors.InvalidArgument(errors.New("pod sync workers must be greater than 0"))
|
||||
return errdefs.InvalidInput("pod sync workers must be greater than 0")
|
||||
}
|
||||
|
||||
var taint *corev1.Taint
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/cpuguy83/strongerrors"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||
"github.com/virtual-kubelet/virtual-kubelet/log"
|
||||
"github.com/virtual-kubelet/virtual-kubelet/trace/opencensus"
|
||||
octrace "go.opencensus.io/trace"
|
||||
@@ -41,7 +41,7 @@ var (
|
||||
func setupTracing(ctx context.Context, c Opts) error {
|
||||
for k := range c.TraceConfig.Tags {
|
||||
if reservedTagNames[k] {
|
||||
return strongerrors.InvalidArgument(errors.Errorf("invalid trace tag %q, must not use a reserved tag key", k))
|
||||
return errdefs.InvalidInputf("invalid trace tag %q, must not use a reserved tag key", k)
|
||||
}
|
||||
}
|
||||
if c.TraceConfig.Tags == nil {
|
||||
@@ -72,10 +72,10 @@ func setupTracing(ctx context.Context, c Opts) error {
|
||||
default:
|
||||
rate, err := strconv.Atoi(c.TraceSampleRate)
|
||||
if err != nil {
|
||||
return strongerrors.InvalidArgument(errors.Wrap(err, "unsupported trace sample rate"))
|
||||
return errdefs.AsInvalidInput(errors.Wrap(err, "unsupported trace sample rate"))
|
||||
}
|
||||
if rate < 0 || rate > 100 {
|
||||
return strongerrors.InvalidArgument(errors.Wrap(err, "trace sample rate must be between 0 and 100"))
|
||||
return errdefs.AsInvalidInput(errors.Wrap(err, "trace sample rate must be between 0 and 100"))
|
||||
}
|
||||
s = octrace.ProbabilitySampler(float64(rate) / 100)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user