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:
@@ -21,8 +21,9 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type GitRepo struct {
|
||||
@@ -106,13 +107,13 @@ func (g *GitRepo) GetFileCommitLabel(filePath string) (string, error) {
|
||||
}
|
||||
|
||||
if !g.isGitRepo {
|
||||
return "", errors.Errorf(`directory: %s doesn't belong to git repository.`, g.dirPath)
|
||||
return "", fmt.Errorf(`directory: %s doesn't belong to git repository.`, g.dirPath)
|
||||
}
|
||||
|
||||
// filepath in the git repository
|
||||
splitPathList := strings.Split(filePath, g.gitRepoRootPath+string(os.PathSeparator))
|
||||
if len(splitPathList) != 2 {
|
||||
return "", errors.Errorf("error finding the git repository path of %s", filePath)
|
||||
return "", fmt.Errorf("error finding the git repository path of %s", filePath)
|
||||
}
|
||||
gitFilePath := splitPathList[1]
|
||||
gitFileStatus := g.status.File(gitFilePath)
|
||||
|
||||
@@ -6,8 +6,9 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/fission/fission/pkg/utils/manager"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission/pkg/utils/manager"
|
||||
)
|
||||
|
||||
func StartServer(ctx context.Context, log *zap.Logger, mgr manager.Interface, svc string, port string, handler http.Handler) {
|
||||
|
||||
+6
-5
@@ -29,7 +29,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"golang.org/x/net/context/ctxhttp"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -75,11 +76,11 @@ func FindAllGlobs(paths ...string) ([]string, error) {
|
||||
// use absolute path to find files
|
||||
path, err := filepath.Abs(p)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error getting absolute path of path '%s'", p)
|
||||
return nil, fmt.Errorf("error getting absolute path of path '%s': %w", p, err)
|
||||
}
|
||||
globs, err := filepath.Glob(path)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("invalid glob %s: %s", path, err)
|
||||
return nil, fmt.Errorf("invalid glob %s: %s", path, err)
|
||||
}
|
||||
files = append(files, globs...)
|
||||
// xxx handle excludeGlobs here
|
||||
@@ -166,7 +167,7 @@ func isHttp2xxSuccessful(status int) bool {
|
||||
func DownloadUrl(ctx context.Context, httpClient *http.Client, url string, localPath string) error {
|
||||
// validate local path for directory traversal attacks
|
||||
if filepath.Clean(localPath) != localPath {
|
||||
return errors.Errorf("invalid local path: %s", localPath)
|
||||
return fmt.Errorf("invalid local path: %s", localPath)
|
||||
}
|
||||
resp, err := ctxhttp.Get(ctx, httpClient, url)
|
||||
if err != nil {
|
||||
@@ -206,7 +207,7 @@ func DownloadUrl(ctx context.Context, httpClient *http.Client, url string, local
|
||||
func GetStringValueFromEnv(envVar string) (string, error) {
|
||||
v := os.Getenv(envVar)
|
||||
if v == "" {
|
||||
return v, errors.New(fmt.Sprintf("Еnvironment variable %s empty", envVar))
|
||||
return v, fmt.Errorf("environment variable %s empty", envVar)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user