mirror of
https://github.com/goharbor/harbor.git
synced 2024-09-27 13:02:59 +02:00
fix: 404 for artifacts requested for repository which does not exist
Signed-off-by: Maksym Trofimenko <maksym@container-registry.com>
This commit is contained in:
parent
522f96b5cf
commit
6ae90996b9
@ -85,13 +85,22 @@ func (a *artifactAPI) ListArtifacts(ctx context.Context, params operation.ListAr
|
|||||||
if err := a.RequireProjectAccess(ctx, params.ProjectName, rbac.ActionList, rbac.ResourceArtifact); err != nil {
|
if err := a.RequireProjectAccess(ctx, params.ProjectName, rbac.ActionList, rbac.ResourceArtifact); err != nil {
|
||||||
return a.SendError(ctx, err)
|
return a.SendError(ctx, err)
|
||||||
}
|
}
|
||||||
|
repositoryName := fmt.Sprintf("%s/%s", params.ProjectName, params.RepositoryName)
|
||||||
|
_, err := a.repoCtl.GetByName(ctx, repositoryName)
|
||||||
|
if err != nil {
|
||||||
|
switch {
|
||||||
|
case errors.IsErr(err, errors.NotFoundCode):
|
||||||
|
return operation.NewListArtifactsNotFound().WithPayload(&models.Errors{Errors: []*models.Error{{Message: "Repository not found"}}})
|
||||||
|
}
|
||||||
|
return a.SendError(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
// set query
|
// set query
|
||||||
query, err := a.BuildQuery(ctx, params.Q, params.Sort, params.Page, params.PageSize)
|
query, err := a.BuildQuery(ctx, params.Q, params.Sort, params.Page, params.PageSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return a.SendError(ctx, err)
|
return a.SendError(ctx, err)
|
||||||
}
|
}
|
||||||
query.Keywords["RepositoryName"] = fmt.Sprintf("%s/%s", params.ProjectName, params.RepositoryName)
|
query.Keywords["RepositoryName"] = repositoryName
|
||||||
|
|
||||||
// set option
|
// set option
|
||||||
option := option(params.WithTag, params.WithImmutableStatus,
|
option := option(params.WithTag, params.WithImmutableStatus,
|
||||||
|
Loading…
Reference in New Issue
Block a user