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:
@@ -27,7 +27,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||
"go.opentelemetry.io/otel"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -53,12 +54,12 @@ func (opts *TestSubCommand) do(input cli.Input) error {
|
||||
fnName := input.String(flagkey.FnName)
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in testing function ")
|
||||
return fmt.Errorf("error in testing function : %w", err)
|
||||
}
|
||||
|
||||
function, err := opts.Client().FissionClientSet.CoreV1().Functions(namespace).Get(input.Context(), fnName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("read function '%s'", fnName))
|
||||
return fmt.Errorf("read function '%s': %w", fnName, err)
|
||||
}
|
||||
|
||||
m := &metav1.ObjectMeta{
|
||||
@@ -68,7 +69,7 @@ func (opts *TestSubCommand) do(input cli.Input) error {
|
||||
|
||||
routerURL, err := util.GetRouterURL(input.Context(), opts.Client())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting router URL")
|
||||
return fmt.Errorf("error getting router URL: %w", err)
|
||||
}
|
||||
fnURI := util.UrlForFunction(m.Name, m.Namespace)
|
||||
if input.IsSet(flagkey.FnSubPath) {
|
||||
@@ -146,7 +147,7 @@ func (opts *TestSubCommand) do(input cli.Input) error {
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error reading response from function")
|
||||
return fmt.Errorf("error reading response from function: %w", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode < 400 {
|
||||
@@ -186,7 +187,7 @@ func doHTTPRequest(ctx context.Context, url string, headers []string, method, bo
|
||||
|
||||
req, err := http.NewRequest(method, url, strings.NewReader(body))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error creating HTTP request")
|
||||
return nil, fmt.Errorf("error creating HTTP request: %w", err)
|
||||
}
|
||||
|
||||
accesstoken, ok := os.LookupEnv(util.FISSION_AUTH_TOKEN)
|
||||
@@ -213,7 +214,7 @@ func doHTTPRequest(ctx context.Context, url string, headers []string, method, bo
|
||||
hc := &http.Client{Transport: otelhttp.NewTransport(http.DefaultTransport)}
|
||||
resp, err := hc.Do(req.WithContext(ctx))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error executing HTTP request")
|
||||
return nil, fmt.Errorf("error executing HTTP request: %w", err)
|
||||
}
|
||||
|
||||
if console.Verbosity >= 2 {
|
||||
|
||||
Reference in New Issue
Block a user