mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 04:48:26 +08:00
chore(deps): remove usage of deprecated package pkg/errors
Signed-off-by: Nicol Draghici <idraghic@cisco.com>
This commit is contained in:
committed by
Ravi Chamarthy
parent
5d1f91a79f
commit
6f0c37079c
@@ -1,10 +1,9 @@
|
||||
package cveinfo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
zerr "zotregistry.io/zot/errors"
|
||||
cvemodel "zotregistry.io/zot/pkg/extensions/search/cve/model"
|
||||
)
|
||||
@@ -75,7 +74,7 @@ func NewCvePageFinder(limit, offset int, sortBy SortCriteria, cveInfo CveInfo) (
|
||||
}
|
||||
|
||||
if _, found := SortFunctions()[sortBy]; !found {
|
||||
return nil, errors.Wrapf(zerr.ErrSortCriteriaNotSupported, "sorting CVEs by '%s' is not supported", sortBy)
|
||||
return nil, fmt.Errorf("sorting CVEs by '%s' is not supported %w", sortBy, zerr.ErrSortCriteriaNotSupported)
|
||||
}
|
||||
|
||||
return &CvePageFinder{
|
||||
|
||||
@@ -3,6 +3,7 @@ package trivy
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path"
|
||||
"sync"
|
||||
|
||||
@@ -14,7 +15,6 @@ import (
|
||||
regTypes "github.com/google/go-containerregistry/pkg/v1/types"
|
||||
godigest "github.com/opencontainers/go-digest"
|
||||
ispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
zerr "zotregistry.io/zot/errors"
|
||||
"zotregistry.io/zot/pkg/extensions/search/common"
|
||||
@@ -197,14 +197,14 @@ func (scanner Scanner) IsImageFormatScannable(repo, tag string) (bool, error) {
|
||||
case ispec.MediaTypeImageManifest:
|
||||
ok, err := scanner.isManifestScanable(imageDescriptor)
|
||||
if err != nil {
|
||||
return ok, errors.Wrapf(err, "image '%s'", image)
|
||||
return ok, fmt.Errorf("image '%s' %w", image, err)
|
||||
}
|
||||
|
||||
return ok, nil
|
||||
case ispec.MediaTypeImageIndex:
|
||||
ok, err := scanner.isIndexScanable(imageDescriptor)
|
||||
if err != nil {
|
||||
return ok, errors.Wrapf(err, "image '%s'", image)
|
||||
return ok, fmt.Errorf("image '%s' %w", image, err)
|
||||
}
|
||||
|
||||
return ok, nil
|
||||
|
||||
@@ -7,6 +7,7 @@ package search
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -14,7 +15,6 @@ import (
|
||||
"github.com/99designs/gqlgen/graphql"
|
||||
godigest "github.com/opencontainers/go-digest"
|
||||
ispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/vektah/gqlparser/v2/gqlerror"
|
||||
|
||||
zerr "zotregistry.io/zot/errors"
|
||||
@@ -890,9 +890,8 @@ func validateGlobalSearchInput(query string, filter *gql_generated.Filter,
|
||||
requestedPage *gql_generated.PageInput,
|
||||
) error {
|
||||
if len(query) > querySizeLimit {
|
||||
format := "global-search: max string size limit exeeded for query parameter. max=%d current=%d"
|
||||
|
||||
return errors.Wrapf(zerr.ErrInvalidRequestParams, format, querySizeLimit, len(query))
|
||||
return fmt.Errorf("global-search: max string size limit exeeded for query parameter. max=%d current=%d %w",
|
||||
querySizeLimit, len(query), zerr.ErrInvalidRequestParams)
|
||||
}
|
||||
|
||||
err := checkFilter(filter)
|
||||
@@ -915,17 +914,15 @@ func checkFilter(filter *gql_generated.Filter) error {
|
||||
|
||||
for _, arch := range filter.Arch {
|
||||
if len(*arch) > querySizeLimit {
|
||||
format := "global-search: max string size limit exeeded for arch parameter. max=%d current=%d"
|
||||
|
||||
return errors.Wrapf(zerr.ErrInvalidRequestParams, format, querySizeLimit, len(*arch))
|
||||
return fmt.Errorf("global-search: max string size limit exeeded for arch parameter. max=%d current=%d %w",
|
||||
querySizeLimit, len(*arch), zerr.ErrInvalidRequestParams)
|
||||
}
|
||||
}
|
||||
|
||||
for _, osSys := range filter.Os {
|
||||
if len(*osSys) > querySizeLimit {
|
||||
format := "global-search: max string size limit exeeded for os parameter. max=%d current=%d"
|
||||
|
||||
return errors.Wrapf(zerr.ErrInvalidRequestParams, format, querySizeLimit, len(*osSys))
|
||||
return fmt.Errorf("global-search: max string size limit exeeded for os parameter. max=%d current=%d %w",
|
||||
querySizeLimit, len(*osSys), zerr.ErrInvalidRequestParams)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -938,15 +935,13 @@ func checkRequestedPage(requestedPage *gql_generated.PageInput) error {
|
||||
}
|
||||
|
||||
if requestedPage.Limit != nil && *requestedPage.Limit < 0 {
|
||||
format := "global-search: requested page limit parameter can't be negative"
|
||||
|
||||
return errors.Wrap(zerr.ErrInvalidRequestParams, format)
|
||||
return fmt.Errorf("global-search: requested page limit parameter can't be negative %w",
|
||||
zerr.ErrInvalidRequestParams)
|
||||
}
|
||||
|
||||
if requestedPage.Offset != nil && *requestedPage.Offset < 0 {
|
||||
format := "global-search: requested page offset parameter can't be negative"
|
||||
|
||||
return errors.Wrap(zerr.ErrInvalidRequestParams, format)
|
||||
return fmt.Errorf("global-search: requested page offset parameter can't be negative %w",
|
||||
zerr.ErrInvalidRequestParams)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -1041,8 +1036,8 @@ func expandedRepoInfo(ctx context.Context, repo string, repoDB repodb.RepoDB, cv
|
||||
|
||||
manifestMeta, err := repoDB.GetManifestMeta(repo, godigest.Digest(digest))
|
||||
if err != nil {
|
||||
graphql.AddError(ctx, errors.Wrapf(err,
|
||||
"resolver: failed to get manifest meta for image %s:%s with manifest digest %s", repo, tag, digest))
|
||||
graphql.AddError(ctx, fmt.Errorf("resolver: failed to get manifest meta for image %s:%s with manifest digest %s %w",
|
||||
repo, tag, digest, err))
|
||||
|
||||
continue
|
||||
}
|
||||
@@ -1057,8 +1052,8 @@ func expandedRepoInfo(ctx context.Context, repo string, repoDB repodb.RepoDB, cv
|
||||
|
||||
indexData, err := repoDB.GetIndexData(godigest.Digest(digest))
|
||||
if err != nil {
|
||||
graphql.AddError(ctx, errors.Wrapf(err,
|
||||
"resolver: failed to get manifest meta for image %s:%s with manifest digest %s", repo, tag, digest))
|
||||
graphql.AddError(ctx, fmt.Errorf("resolver: failed to get manifest meta for image %s:%s with manifest digest %s %w",
|
||||
repo, tag, digest, err))
|
||||
|
||||
continue
|
||||
}
|
||||
@@ -1067,8 +1062,8 @@ func expandedRepoInfo(ctx context.Context, repo string, repoDB repodb.RepoDB, cv
|
||||
|
||||
err = json.Unmarshal(indexData.IndexBlob, &indexContent)
|
||||
if err != nil {
|
||||
graphql.AddError(ctx, errors.Wrapf(err,
|
||||
"resolver: failed to unmarshal index content for image %s:%s with digest %s", repo, tag, digest))
|
||||
graphql.AddError(ctx, fmt.Errorf("resolver: failed to unmarshal index content for image %s:%s with digest %s %w",
|
||||
repo, tag, digest, err))
|
||||
|
||||
continue
|
||||
}
|
||||
@@ -1078,9 +1073,9 @@ func expandedRepoInfo(ctx context.Context, repo string, repoDB repodb.RepoDB, cv
|
||||
for _, descriptor := range indexContent.Manifests {
|
||||
manifestMeta, err := repoDB.GetManifestMeta(repo, descriptor.Digest)
|
||||
if err != nil {
|
||||
graphql.AddError(ctx, errors.Wrapf(err,
|
||||
"resolver: failed to get manifest meta with digest '%s' for multiarch image %s:%s",
|
||||
digest, repo, tag),
|
||||
graphql.AddError(ctx,
|
||||
fmt.Errorf("resolver: failed to get manifest meta with digest '%s' for multiarch image %s:%s %w",
|
||||
digest, repo, tag, err),
|
||||
)
|
||||
|
||||
errorOccured = true
|
||||
@@ -1200,8 +1195,8 @@ func getReferrers(repoDB repodb.RepoDB, repo string, referredDigest string, arti
|
||||
if err := refDigest.Validate(); err != nil {
|
||||
log.Error().Err(err).Msgf("graphql: bad digest string from request '%s'", referredDigest)
|
||||
|
||||
return []*gql_generated.Referrer{}, errors.Wrapf(err, "graphql: bad digest string from request '%s'",
|
||||
referredDigest)
|
||||
return []*gql_generated.Referrer{}, fmt.Errorf("graphql: bad digest string from request '%s' %w",
|
||||
referredDigest, err)
|
||||
}
|
||||
|
||||
referrers, err := repoDB.GetFilteredReferrersInfo(repo, refDigest, artifactTypes)
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
godigest "github.com/opencontainers/go-digest"
|
||||
ispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
artifactspec "github.com/oras-project/artifacts-spec/specs-go/v1"
|
||||
perr "github.com/pkg/errors"
|
||||
"github.com/sigstore/cosign/cmd/cosign/cli/generate"
|
||||
"github.com/sigstore/cosign/cmd/cosign/cli/options"
|
||||
"github.com/sigstore/cosign/cmd/cosign/cli/sign"
|
||||
@@ -5284,7 +5283,7 @@ func pushRepo(url, repoName string) godigest.Digest {
|
||||
}
|
||||
|
||||
if resp.StatusCode() != http.StatusAccepted {
|
||||
panic(perr.Wrapf(errBadStatus, "invalid status code: %d", resp.StatusCode()))
|
||||
panic(fmt.Errorf("invalid status code: %d %w", resp.StatusCode(), errBadStatus))
|
||||
}
|
||||
|
||||
loc = test.Location(url, resp)
|
||||
@@ -5302,7 +5301,7 @@ func pushRepo(url, repoName string) godigest.Digest {
|
||||
}
|
||||
|
||||
if resp.StatusCode() != http.StatusCreated {
|
||||
panic(perr.Wrapf(errBadStatus, "invalid status code: %d", resp.StatusCode()))
|
||||
panic(fmt.Errorf("invalid status code: %d %w", resp.StatusCode(), errBadStatus))
|
||||
}
|
||||
|
||||
// create a manifest
|
||||
@@ -5437,7 +5436,7 @@ func pushBlob(url string, repoName string, buf []byte) godigest.Digest {
|
||||
}
|
||||
|
||||
if resp.StatusCode() != http.StatusAccepted {
|
||||
panic(perr.Wrapf(errBadStatus, "invalid status code: %d", resp.StatusCode()))
|
||||
panic(fmt.Errorf("invalid status code: %d %w", resp.StatusCode(), errBadStatus))
|
||||
}
|
||||
|
||||
loc := test.Location(url, resp)
|
||||
@@ -5456,7 +5455,7 @@ func pushBlob(url string, repoName string, buf []byte) godigest.Digest {
|
||||
}
|
||||
|
||||
if resp.StatusCode() != http.StatusCreated {
|
||||
panic(perr.Wrapf(errBadStatus, "invalid status code: %d", resp.StatusCode()))
|
||||
panic(fmt.Errorf("invalid status code: %d %w", resp.StatusCode(), errBadStatus))
|
||||
}
|
||||
|
||||
return digest
|
||||
|
||||
Reference in New Issue
Block a user