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:
Sanket Sudake
2025-02-20 08:58:37 +05:30
committed by GitHub
parent 2fd44174ce
commit caffed92f4
113 changed files with 585 additions and 588 deletions
+2 -2
View File
@@ -18,6 +18,7 @@ package storagesvc
import (
"context"
"fmt"
"time"
"go.uber.org/zap"
@@ -27,7 +28,6 @@ import (
"github.com/fission/fission/pkg/generated/clientset/versioned"
"github.com/fission/fission/pkg/utils"
"github.com/fission/fission/pkg/utils/manager"
"github.com/pkg/errors"
)
type ArchivePruner struct {
@@ -43,7 +43,7 @@ const defaultPruneInterval int = 60 // in minutes
func MakeArchivePruner(logger *zap.Logger, clientGen crd.ClientGeneratorInterface, stowClient *StowClient, pruneInterval time.Duration) (*ArchivePruner, error) {
fissionClient, err := clientGen.GetFissionClient()
if err != nil {
return nil, errors.Wrap(err, "failed to get fission client")
return nil, fmt.Errorf("failed to get fission client: %w", err)
}
return &ArchivePruner{
+4 -3
View File
@@ -28,7 +28,8 @@ import (
"os"
"strings"
"github.com/pkg/errors"
"errors"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"golang.org/x/net/context/ctxhttp"
@@ -160,7 +161,7 @@ func (c *client) Download(ctx context.Context, id string, filePath string) error
// quit if file exists
_, err := os.Stat(filePath)
if err == nil || !os.IsNotExist(err) {
return errors.Errorf("file already exists: %v", filePath)
return fmt.Errorf("file already exists: %v", filePath)
}
// create
@@ -223,7 +224,7 @@ func (c *client) Delete(ctx context.Context, id string) error {
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return errors.Errorf("HTTP error %v", resp.StatusCode)
return fmt.Errorf("HTTP error %v", resp.StatusCode)
}
return nil
+2 -1
View File
@@ -3,9 +3,10 @@ package storagesvc
import (
"os"
"github.com/fission/fission/pkg/utils/uuid"
"github.com/graymeta/stow"
_ "github.com/graymeta/stow/local"
"github.com/fission/fission/pkg/utils/uuid"
)
type localStorage struct {
+4 -3
View File
@@ -25,9 +25,10 @@ import (
"strconv"
"time"
"errors"
"github.com/gorilla/mux"
"github.com/graymeta/stow"
"github.com/pkg/errors"
"go.uber.org/zap"
"github.com/fission/fission/pkg/crd"
@@ -292,7 +293,7 @@ func Start(ctx context.Context, clientGen crd.ClientGeneratorInterface, logger *
// create a storage client
storageClient, err := MakeStowClient(logger, storage)
if err != nil {
return errors.Wrap(err, "Error creating stowClient")
return fmt.Errorf("Error creating stowClient: %w", err)
}
// create http handlers
@@ -314,7 +315,7 @@ func Start(ctx context.Context, clientGen crd.ClientGeneratorInterface, logger *
}
pruner, err := MakeArchivePruner(logger, clientGen, storageClient, time.Duration(pruneInterval))
if err != nil {
return errors.Wrap(err, "Error creating archivePruner")
return fmt.Errorf("Error creating archivePruner: %w", err)
}
mgr.Add(ctx, func(ctx context.Context) {
pruner.Start(ctx, mgr)
+3 -2
View File
@@ -24,8 +24,9 @@ import (
"strings"
"time"
"errors"
"github.com/graymeta/stow"
"github.com/pkg/errors"
"go.uber.org/zap"
)
@@ -208,7 +209,7 @@ func (client *StowClient) getItemIDsWithFilter(filterFunc filter, filterFuncPara
for {
items, cursor, err = client.container.Items(client.config.storage.getSubDir(), cursor, PaginationSize)
if err != nil {
return nil, errors.Wrap(err, "error getting items from container")
return nil, fmt.Errorf("error getting items from container: %w", err)
}
for _, item := range items {
+2 -3
View File
@@ -17,15 +17,14 @@ limitations under the License.
package storagesvc
import (
"fmt"
"net/url"
"github.com/pkg/errors"
)
func getQueryParamValue(urlString string, queryParam string) (string, error) {
url, err := url.Parse(urlString)
if err != nil {
return "", errors.Wrapf(err, "error parsing URL string %q into URL", urlString)
return "", fmt.Errorf("error parsing URL string %q into URL: %w", urlString, err)
}
return url.Query().Get(queryParam), nil
}