unioslo / harborapi

Python async client for the Harbor REST API v2.0.
https://unioslo.github.io/harborapi/
MIT License
27 stars 5 forks source link

API to fetch all the chart versions based on the chart name #37

Closed sivachandran-s closed 1 year ago

sivachandran-s commented 1 year ago

Hi @pederhan ,

Could you please guide me to get all the chart versions based on the chart name, currently the /search endpoints display only one version not listing all the available versions.

Example:

helm search repo --versions NAME CHART VERSION APP VERSION DESCRIPTION

230306 230306 A Helm chart for Kubernetes 1689 1.16.0 A Helm chart for Kubernetes 1.6.89 1.16.0 A Helm chart for Kubernetes curl -X GET "https://url/api/v2.0/search?q=repo%name" -H "accept: application/json" -u "username":"password" -k The above curl call only displays the 230306 chart version details and it is not displaying the details for the other two versions.
pederhan commented 1 year ago

It doesn't seem to be supported by the 2.0 API yet from what I can tell, but I found out that it exists at https://demo.goharbor.io/api/chartrepo/{repo}/charts/{chartname}.

Example output (GET https://demo.goharbor.io/api/chartrepo/testproj/charts/nginx):

[
    {
        "name": "nginx",
        "home": "https://github.com/bitnami/charts/tree/main/bitnami/nginx",
        "sources": [
            "https://github.com/bitnami/containers/tree/main/bitnami/nginx",
            "https://www.nginx.org"
        ],
        "version": "13.2.29",
        "description": "NGINX Open Source is a web server that can be also used as a reverse proxy, load balancer, and HTTP cache. Recommended for high-demanding sites due to its ability to provide faster content.",
        "keywords": [
            "nginx",
            "http",
            "web",
            "www",
            "reverse proxy"
        ],
        "maintainers": [
            {
                "name": "Bitnami",
                "url": "https://github.com/bitnami/charts"
            }
        ],
        "icon": "https://bitnami.com/assets/stacks/nginx/img/nginx-stack-220x234.png",
        "apiVersion": "v2",
        "appVersion": "1.23.3",
        "annotations": {
            "category": "Infrastructure",
            "licenses": "Apache-2.0"
        },
        "dependencies": [
            {
                "name": "common",
                "version": "2.x.x",
                "repository": "https://charts.bitnami.com/bitnami",
                "tags": [
                    "bitnami-common"
                ]
            }
        ],
        "urls": [
            "charts/nginx-13.2.29.tgz"
        ],
        "created": "2023-03-15T08:59:19.284147194Z",
        "digest": "f5f043331b20bca1f795a290bd9ab206bd7eaf91d262cc193cfe3c1daa8604c1",
        "labels": []
    },
    # ... other versions here
]

Adding support for an older version of the API is out of scope for now, but if the Harbor devs express that they have no plans to add this to the 2.0 API I'll have a look at implementing it in this library myself.

sivachandran-s commented 1 year ago

Understood @pederhan Thank you for sharing the API which you shared seems working.