goharbor / harbor

An open source trusted cloud native registry project that stores, signs, and scans content.
https://goharbor.io
Apache License 2.0
24.03k stars 4.75k forks source link

Add "List all artifacts" to REST API #21010

Open brianmajor opened 3 weeks ago

brianmajor commented 3 weeks ago

In order to list all artifacts across all repositories and projects, one currently has to iterate through each of those items with separate REST API calls:

get all projects (GET to /projects)
    for each project
        get all repositories (GET to /{project}/repository)
            for each repository
                get all artifacts (GET to /{project}/{repository}/artifacts)
                    add to list

This results in an unscalable number of calls.

A single REST API call to get all the artifacts in all repositories and projects.

This would be scalable because the complexity can be handled in the DB query.

In the meantime, I wonder if there is an alternate approach we could use to get the list of all images?

Thesuperkingofsnakes22 commented 3 weeks ago

در تاریخ سه‌شنبه ۸ اکتبر ۲۰۲۴،‏ ۰۲:۱۷ Brian Major @.***> نوشت:

In order to list all artifacts across all repositories and projects, one currently has to iterate through each of those items with separate REST API calls:

get all projects (GET to /projects) for each project get all repositories (GET to /{project}/repository) for each repository get all artifacts (GET to /{project}/{repository}/artifacts) add to list

This results in an unscalable number of calls.

A single REST API call to get all the artifacts in all repositories and projects.

This would be scalable because the complexity can be handled in the DB query.

In the meantime, I wonder if there is an alternate approach we could use to get the list of all images?

— Reply to this email directly, view it on GitHub https://github.com/goharbor/harbor/issues/21010, or unsubscribe https://github.com/notifications/unsubscribe-auth/BLANCFEKR7AXJXWEUQCC2CDZ2MFQVAVCNFSM6AAAAABPQ5KJ6CVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU3TCNRWGI4TCNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Thesuperkingofsnakes22 commented 3 weeks ago

In order to list all artifacts across all repositories and projects, one currently has to iterate through each of those items with separate REST API calls:

get all projects (GET to /projects)
    for each project
        get all repositories (GET to /{project}/repository)
            for each repository
                get all artifacts (GET to /{project}/{repository}/artifacts)
                    add to list

This results in an unscalable number of calls.

A single REST API call to get all the artifacts in all repositories and projects.

This would be scalable because the complexity can be handled in the DB query.

In the meantime, I wonder if there is an alternate approach we could use to get the list of all images?

wy65701436 commented 2 weeks ago

can you clarify the requirement in details? Like, you would like to have a api to list all the artifacts that belong to one specific project.

brianmajor commented 2 weeks ago

The use case is driven by users' need to discover what images are available to them in a given harbor instance. This would be across all projects (but authorization would be applied on a project-to-project basis I presume). We would like to use the harbor API to generate this list, present it to users, and then integrate the users' selection with other (non-harbor) APIs that use the images.

wy65701436 commented 1 week ago

Currently, we do have the api to list all the artifacts that belong to one specific project.

brianmajor commented 6 days ago

Currently, we do have the api to list all the artifacts that belong to one specific project.

Oh, that would certainly help. But I must be missing something, as the only GET to artifacts I see in the v2.0 API requires the repository_name as well:

GET /projects/{project_name}/repositories/{repository_name}/artifacts