Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore Ansible Galaxy Collection with new APIs #10916

Closed
artis3n opened this issue Mar 2, 2025 · 5 comments
Closed

Restore Ansible Galaxy Collection with new APIs #10916

artis3n opened this issue Mar 2, 2025 · 5 comments
Labels
good first issue New contributors, join in! service-badge New or updated service badge

Comments

@artis3n
Copy link
Contributor

artis3n commented Mar 2, 2025

📋 Description

A while back, #9631 documented the trials of RedHat making sudden, breaking changes to Ansible Galaxy's APIs. In it, several Ansible-related badges were deprecated because the APIs just disappeared without replacements.

There now appears to be some new values worth making badges for:

https://galaxy.ansible.com/api/v3/plugin/ansible/content/published/collections/index/NAMESPACE/NAME/ has data about the latest version of an Ansible Collection and the total download count of that collection.

Would love a Collection version of https://shields.io/badges/ansible-role that could track how many times a collection is downloaded.

Data structure appears to be (using a newly published collection of mine):

{
    "href": "/api/v3/plugin/ansible/content/published/collections/index/artis3n/tailscale/",
    "namespace": "artis3n",
    "name": "tailscale",
    "deprecated": false,
    "versions_url": "/api/v3/plugin/ansible/content/published/collections/index/artis3n/tailscale/versions/",
    "highest_version": {
        "href": "/api/v3/plugin/ansible/content/published/collections/index/artis3n/tailscale/versions/0.1.0/",
        "version": "0.1.0"
    },
    "created_at": "2025-03-01T21:20:09.413588Z",
    "updated_at": "2025-03-01T21:20:09.463529Z",
    "download_count": 18
}

So we could take .download_count for a badge, and perhaps a second badge extracting .highest_version.version for a version badge.

@chris48s
Copy link
Member

chris48s commented Mar 2, 2025

@chris48s chris48s added good first issue New contributors, join in! service-badge New or updated service badge labels Mar 2, 2025
@artis3n
Copy link
Contributor Author

artis3n commented Mar 8, 2025

@chris48s
Copy link
Member

chris48s commented Mar 8, 2025

Thanks. Good question.

I reckon the routes for the new badges should be

  • ansible/collection/d/{collection} for downloads
  • ansible/collection/v/{collection} for version

but if you leave the deprecatedService in place, that will continue to serve the "no longer available" badge for (for example) https://img.shields.io/ansible/collection/foobar

That is similar to what we did with roles
https://github.com/badges/shields/blob/master/services/ansible/ansible-role.service.js
You can either split that out into several files or put them all in one.

@artis3n
Copy link
Contributor Author

artis3n commented Mar 9, 2025

Starting with #10937 so I can actually build the repo :D

@artis3n
Copy link
Contributor Author

artis3n commented Mar 9, 2025

PR up - #10938

I also am getting local test failures but the endpoint works fine and CI tests pass. Not sure how I'm testing wrong locally!
#10938 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue New contributors, join in! service-badge New or updated service badge
Projects
None yet
Development

No branches or pull requests

2 participants