Use errdefs package
This commit is contained in:
@@ -18,8 +18,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/cpuguy83/strongerrors"
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/version"
|
"github.com/virtual-kubelet/virtual-kubelet/version"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
@@ -100,7 +99,7 @@ func getTaint(c Opts) (*corev1.Taint, error) {
|
|||||||
case "PreferNoSchedule":
|
case "PreferNoSchedule":
|
||||||
effect = corev1.TaintEffectPreferNoSchedule
|
effect = corev1.TaintEffectPreferNoSchedule
|
||||||
default:
|
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{
|
return &corev1.Taint{
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cpuguy83/strongerrors"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/log"
|
"github.com/virtual-kubelet/virtual-kubelet/log"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/manager"
|
"github.com/virtual-kubelet/virtual-kubelet/manager"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
"github.com/virtual-kubelet/virtual-kubelet/providers"
|
||||||
@@ -64,11 +64,11 @@ func runRootCommand(ctx context.Context, c Opts) error {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
if ok := providers.ValidOperatingSystems[c.OperatingSystem]; !ok {
|
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 {
|
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
|
var taint *corev1.Taint
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/cpuguy83/strongerrors"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/log"
|
"github.com/virtual-kubelet/virtual-kubelet/log"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/trace/opencensus"
|
"github.com/virtual-kubelet/virtual-kubelet/trace/opencensus"
|
||||||
octrace "go.opencensus.io/trace"
|
octrace "go.opencensus.io/trace"
|
||||||
@@ -41,7 +41,7 @@ var (
|
|||||||
func setupTracing(ctx context.Context, c Opts) error {
|
func setupTracing(ctx context.Context, c Opts) error {
|
||||||
for k := range c.TraceConfig.Tags {
|
for k := range c.TraceConfig.Tags {
|
||||||
if reservedTagNames[k] {
|
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 {
|
if c.TraceConfig.Tags == nil {
|
||||||
@@ -72,10 +72,10 @@ func setupTracing(ctx context.Context, c Opts) error {
|
|||||||
default:
|
default:
|
||||||
rate, err := strconv.Atoi(c.TraceSampleRate)
|
rate, err := strconv.Atoi(c.TraceSampleRate)
|
||||||
if err != nil {
|
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 {
|
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)
|
s = octrace.ProbabilitySampler(float64(rate) / 100)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user