App.LatestVersion() broken because maps are unordered #44

Closed
opened 2021-08-06 12:54:08 +00:00 by decentral1se · 0 comments
Owner

We currently have LatestVersion function which purports to return the latest version of a recipe by iterating over a map of the versions listed for a recipe in the apps.json. This doesn't work because Golang maps are unordered. A potentially new version is returned each time...

Looks like this is actually broken in abra-bash also since we are doing mapfile -t RECIPE_VERSIONS < <(echo "$recipe_json" | $JQ -r ".versions | keys | .[]" - | sort) but a sort is not necessarily the actual latest/oldest order we need!

For example, wget -q https://registry.hub.docker.com/v1/repositories/gitea/gitea/tags -O - | jq -r '.[].name' returns the wrong order as well.

We could use a list instead in the apps.json. This would work because in the app-json.py script, we run a local git tags -l and iterate backwards through them - a latest/oldest order which we control (not upstream or Docker Hub).

We'd have to do the following:

/cc @roxxers @3wordchant

We currently have `LatestVersion` function which purports to return the latest version of a recipe by iterating over a map of the versions listed for a recipe in the `apps.json`. This doesn't work because Golang maps are unordered. A potentially new version is returned each time... Looks like this is actually broken in `abra-bash` also since we are doing `mapfile -t RECIPE_VERSIONS < <(echo "$recipe_json" | $JQ -r ".versions | keys | .[]" - | sort)` but a `sort` is not necessarily the actual latest/oldest order we need! For example, `wget -q https://registry.hub.docker.com/v1/repositories/gitea/gitea/tags -O - | jq -r '.[].name'` returns the wrong order as well. We could use a list instead in the `apps.json`. This would work because in the `app-json.py` script, we run a local `git tags -l` and iterate backwards through them - a latest/oldest order which we control (not upstream or Docker Hub). We'd have to do the following: - Change [`get_app_versions`](https://git.coopcloud.tech/coop-cloud/abra/src/commit/36e470c8e7129b20d8245b69192a04aafd798b85/bin/app-json.py#L142-L213) to return a list in `app-json.py` - Change `abra-bash` to understand this new list in [`get_recipe_versions`](https://git.coopcloud.tech/coop-cloud/abra/src/commit/36e470c8e7129b20d8245b69192a04aafd798b85/abra#L695-L707) and make a new point release - Re-upload the the `apps.json` to https://apps.coopcloud.tech /cc @roxxers @3wordchant
decentral1se added the
bug
label 2021-08-06 12:54:08 +00:00
decentral1se added this to the (deleted) milestone 2021-09-04 21:03:19 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: toolshed/abra#44
No description provided.