buildpacks / registry-api

API for searching and reading the Buildpack Registry
Apache License 2.0
3 stars 8 forks source link

Cast buildpack semver parts to integer when sorting #81

Closed ryanmoran closed 2 years ago

ryanmoran commented 2 years ago

I'm not sure that this is the right thing to do, but the current sorting mechanism does a string sort on the semver parts of a buildpack version. This results in an api response for a buildpack with a version series like [0.8.0, 0.9.0, 0.10.0] that specifies 0.9.0 as the latest version instead of 0.10.0.

For a real world example, check out the response for https://cnb-registry-api-staging.herokuapp.com//api/v1/buildpacks/paketo-buildpacks/python, which looks like the following:

{
  "latest": {
    "description": "",
    "homepage": "",
    "id": "65ae76da-0928-4635-9738-05100e8a82a5",
    "licenses": null,
    "name": "python",
    "namespace": "paketo-buildpacks",
    "stacks": [
      "io.buildpacks.stacks.bionic"
    ],
    "version": "0.9.0"
  },
  "versions": [
    {
      "_link": "https://cnb-registry-api-staging.herokuapp.com//api/v1/buildpacks/paketo-buildpacks/python/0.9.0",
      "version": "0.9.0"
    },
    {
      "_link": "https://cnb-registry-api-staging.herokuapp.com//api/v1/buildpacks/paketo-buildpacks/python/0.8.1",
      "version": "0.8.1"
    },
    {
      "_link": "https://cnb-registry-api-staging.herokuapp.com//api/v1/buildpacks/paketo-buildpacks/python/0.8.0",
      "version": "0.8.0"
    },
    {
      "_link": "https://cnb-registry-api-staging.herokuapp.com//api/v1/buildpacks/paketo-buildpacks/python/0.10.0",
      "version": "0.10.0"
    }
  ]
}
jkutner commented 2 years ago

@ryanmoran thanks for this! I'm on vacation this week, but I'll review early next week. In the meantime, can you DCO your commit? thanks

jkutner commented 2 years ago

Sorry it took so long to get this in. Thanks!