Remove github.com/pkg/errors with appropriate replacements (#3172)
* errors.Wrap* removal Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * remove errors.Errorf Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * Remove remaining calls Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * Few more errors Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * Fix golint errors Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> --------- Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -29,7 +29,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||
"go.uber.org/zap"
|
||||
k8stypes "k8s.io/apimachinery/pkg/types"
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
k8sCache "k8s.io/client-go/tools/cache"
|
||||
@@ -111,7 +110,7 @@ func (frr *functionReferenceResolver) resolve(trigger fv1.HTTPTrigger) (*resolve
|
||||
}
|
||||
|
||||
default:
|
||||
return nil, errors.Errorf("unrecognized function reference type %v", trigger.Spec.FunctionReference.Type)
|
||||
return nil, fmt.Errorf("unrecognized function reference type %v", trigger.Spec.FunctionReference.Type)
|
||||
}
|
||||
|
||||
// cache resolve result
|
||||
@@ -145,7 +144,7 @@ func (frr *functionReferenceResolver) resolveByName(namespace, name string) (*re
|
||||
}
|
||||
if !isExist {
|
||||
frr.logger.Error("function does not exists", zap.String("name", name), zap.String("namespace", namespace))
|
||||
return nil, errors.Errorf("function %s/%s does not exist", namespace, name)
|
||||
return nil, fmt.Errorf("function %s/%s does not exist", namespace, name)
|
||||
}
|
||||
f := obj.(*fv1.Function)
|
||||
|
||||
|
||||
+11
-12
@@ -47,7 +47,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.uber.org/zap"
|
||||
|
||||
@@ -91,7 +90,7 @@ func serve(ctx context.Context, logger *zap.Logger, mgr manager.Interface, port
|
||||
httpTriggerSet *HTTPTriggerSet, displayAccessLog bool) error {
|
||||
mr, err := router(ctx, logger, mgr, httpTriggerSet)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error making router")
|
||||
return fmt.Errorf("error making router: %w", err)
|
||||
}
|
||||
handler := otelUtils.GetHandlerWithOTEL(mr, "fission-router", otelUtils.UrlsToIgnore("/router-healthz"))
|
||||
mgr.Add(ctx, func(ctx context.Context) {
|
||||
@@ -106,52 +105,52 @@ func Start(ctx context.Context, clientGen crd.ClientGeneratorInterface, logger *
|
||||
|
||||
fissionClient, err := clientGen.GetFissionClient()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error making the fission client")
|
||||
return fmt.Errorf("error making the fission client: %w", err)
|
||||
}
|
||||
kubeClient, err := clientGen.GetKubernetesClient()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error making the kube client")
|
||||
return fmt.Errorf("error making the kube client: %w", err)
|
||||
}
|
||||
|
||||
err = crd.WaitForFunctionCRDs(ctx, logger, fissionClient)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error waiting for CRDs")
|
||||
return fmt.Errorf("error waiting for CRDs: %w", err)
|
||||
}
|
||||
|
||||
timeoutStr := os.Getenv("ROUTER_ROUND_TRIP_TIMEOUT")
|
||||
timeout, err := time.ParseDuration(timeoutStr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to parse timeout duration value('%s') from 'ROUTER_ROUND_TRIP_TIMEOUT'", timeoutStr))
|
||||
return fmt.Errorf("failed to parse timeout duration value('%s') from 'ROUTER_ROUND_TRIP_TIMEOUT': %w", timeoutStr, err)
|
||||
}
|
||||
|
||||
timeoutExponentStr := os.Getenv("ROUTER_ROUNDTRIP_TIMEOUT_EXPONENT")
|
||||
timeoutExponent, err := strconv.Atoi(timeoutExponentStr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to parse timeout exponent value('%s') from 'ROUTER_ROUNDTRIP_TIMEOUT_EXPONENT'", timeoutExponentStr))
|
||||
return fmt.Errorf("failed to parse timeout exponent value('%s') from 'ROUTER_ROUNDTRIP_TIMEOUT_EXPONENT': %w", timeoutExponentStr, err)
|
||||
}
|
||||
|
||||
keepAliveTimeStr := os.Getenv("ROUTER_ROUND_TRIP_KEEP_ALIVE_TIME")
|
||||
keepAliveTime, err := time.ParseDuration(keepAliveTimeStr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to parse keep alive duration value('%s') from 'ROUTER_ROUND_TRIP_KEEP_ALIVE_TIME'", keepAliveTimeStr))
|
||||
return fmt.Errorf("failed to parse keep alive duration value('%s') from 'ROUTER_ROUND_TRIP_KEEP_ALIVE_TIME': %w", keepAliveTimeStr, err)
|
||||
}
|
||||
|
||||
disableKeepAliveStr := os.Getenv("ROUTER_ROUND_TRIP_DISABLE_KEEP_ALIVE")
|
||||
disableKeepAlive, err := strconv.ParseBool(disableKeepAliveStr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to parse enable keep alive value('%s') from 'ROUTER_ROUND_TRIP_DISABLE_KEEP_ALIVE'", disableKeepAliveStr))
|
||||
return fmt.Errorf("failed to parse enable keep alive value('%s') from 'ROUTER_ROUND_TRIP_DISABLE_KEEP_ALIVE': %w", disableKeepAliveStr, err)
|
||||
}
|
||||
|
||||
maxRetriesStr := os.Getenv("ROUTER_ROUND_TRIP_MAX_RETRIES")
|
||||
maxRetries, err := strconv.Atoi(maxRetriesStr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to parse max retries value('%s') from 'ROUTER_ROUND_TRIP_MAX_RETRIES'", maxRetriesStr))
|
||||
return fmt.Errorf("failed to parse max retries value('%s') from 'ROUTER_ROUND_TRIP_MAX_RETRIES': %w", maxRetriesStr, err)
|
||||
}
|
||||
|
||||
isDebugEnvStr := os.Getenv("DEBUG_ENV")
|
||||
isDebugEnv, err := strconv.ParseBool(isDebugEnvStr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to parse debug env value('%s') from 'DEBUG_ENV'", isDebugEnvStr))
|
||||
return fmt.Errorf("failed to parse debug env value('%s') from 'DEBUG_ENV': %w", isDebugEnvStr, err)
|
||||
}
|
||||
|
||||
// svcAddrRetryCount is the max times for RetryingRoundTripper to retry with a specific service address
|
||||
@@ -207,7 +206,7 @@ func Start(ctx context.Context, clientGen crd.ClientGeneratorInterface, logger *
|
||||
svcAddrRetryCount: svcAddrRetryCount,
|
||||
}, isDebugEnv, unTapServiceTimeout, throttler.MakeThrottler(svcAddrUpdateTimeout))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error making HTTP trigger set")
|
||||
return fmt.Errorf("error making HTTP trigger set: %w", err)
|
||||
}
|
||||
|
||||
mgr.Add(ctx, func(ctx context.Context) {
|
||||
|
||||
Reference in New Issue
Block a user