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

Add versions.json #516

Merged
merged 3 commits into from
Jun 19, 2023
Merged

Add versions.json #516

merged 3 commits into from
Jun 19, 2023

Conversation

PhrozenByte
Copy link
Contributor

versions.json contains information about the MariaDB versions available in this repo (and therefore also on Docker Hub).

It was inspired by PHP's versions.json, but was adapted to better fit MariaDB's needs. The information in versions.json is currently scattered across the repo and often just accessible by humans, e.g. right now it's impossible to reliably determine the latest full version of containerized MariaDB 10.5 programmatically. The only way is to either fiddle around with sed on the Dockerfile, or to build the container.

This PR also fixes some issues with jq in update.sh. The previous jq script to determine the MariaDB version of a given milestone (mariaversion() function) was a bit weird (recursively searching for a .release_id key even caused my jq to exit with a non-zero status code, causing update.sh to fail; the REST API response has a known structure), so I replaced it. I also switched to jq -r (enabling raw output), so that Bash doesn't have to remove the quotes first. See a57a46c.

versions.json is managed by ./update.sh, see cb3db38. There's no need to edit this file manually (even when adding/removing milestones), just run ./update.sh. If you pass arguments to update.sh, it will update the entries of the given versions in versions.json only. See b72beb4 for an example.

{
  "11.1": {
    "milestone": "11.1",
    "version": "11.1.1",
    "fullVersion": "1:11.1.1+maria~ubu2204",
    "releaseStatus": "RC",
    "supportType": "Short Term Support",
    "base": "ubuntu:jammy",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "11.0": {
    "milestone": "11.0",
    "version": "11.0.2",
    "fullVersion": "1:11.0.2+maria~ubu2204",
    "releaseStatus": "Stable",
    "supportType": "Short Term Support",
    "base": "ubuntu:jammy",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "10.11": {
    "milestone": "10.11",
    "version": "10.11.4",
    "fullVersion": "1:10.11.4+maria~ubu2204",
    "releaseStatus": "Stable",
    "supportType": "Long Term Support",
    "base": "ubuntu:jammy",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "10.10": {
    "milestone": "10.10",
    "version": "10.10.5",
    "fullVersion": "1:10.10.5+maria~ubu2204",
    "releaseStatus": "Stable",
    "supportType": "Short Term Support",
    "base": "ubuntu:jammy",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "10.9": {
    "milestone": "10.9",
    "version": "10.9.7",
    "fullVersion": "1:10.9.7+maria~ubu2204",
    "releaseStatus": "Stable",
    "supportType": "Short Term Support",
    "base": "ubuntu:jammy",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "10.6": {
    "milestone": "10.6",
    "version": "10.6.14",
    "fullVersion": "1:10.6.14+maria~ubu2004",
    "releaseStatus": "Stable",
    "supportType": "Long Term Support",
    "base": "ubuntu:focal",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "10.5": {
    "milestone": "10.5",
    "version": "10.5.21",
    "fullVersion": "1:10.5.21+maria~ubu2004",
    "releaseStatus": "Stable",
    "supportType": "Long Term Support",
    "base": "ubuntu:focal",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "10.4": {
    "milestone": "10.4",
    "version": "10.4.30",
    "fullVersion": "1:10.4.30+maria~ubu2004",
    "releaseStatus": "Stable",
    "supportType": "Long Term Support",
    "base": "ubuntu:focal",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le"
    ]
  },
  "11.2": {
    "milestone": "11.2",
    "version": "11.2.0",
    "fullVersion": "1:11.2.0+maria~ubu2204",
    "releaseStatus": "Alpha",
    "supportType": "Unknown",
    "base": "ubuntu:jammy",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  }
}

- Using `jq -r` makes removing quotes from strings unnecessary
- Overhaul jq script of mariaversion() to identify a milestone's latest version
'versions.json' contains information about the versions available in this repo. It is managed by `./update.sh`; there's no need to edit this file manually, just run `./update.sh`.
@grooverdan
Copy link
Member

Thanks for the contribution and fixing my clunky update.sh.

It looks ok, but I'm still trying understand the actual users of the version.json file. Even by committing here its a day or so out on release day.

Other programmatic ways:

$ podman inspect --format '{{range $key, $value := .Labels}}{{if (eq $key "org.opencontainers.image.version")}}{{$value}}{{end}}{{end}}' mariadb:10.5
10.5.21
$ curl -s https://downloads.mariadb.org/rest-api/mariadb/10.5 | jq  '.releases | keys_unsorted[0]'
"10.5.21"

(also suffers from delay accuracy)

@PhrozenByte
Copy link
Contributor Author

The idea of versions.json is to provide information about the container images that can be built with the Dockerfiles in this repo (i.e. versions.json is not added to the image, it's purely metadata about this repo). It aids people using these Dockerfiles to build their own images, like myself (I'm not actually using Docker, but Podman resp. building my containers with Buildah, allowing me to easily adapt the Dockerfile to fit my needs).

Accessing the latest MariaDB version is just an example, the same applies to any of the information provided in versions.json, e.g. the available milestones, or the available arches. All this information is available somewhere in this repo (e.g. listing milestones is rather easy, listing arches is not); the idea of versions.json is just to have it in one easily accessible place. The goal is not to impose much maintenance effort on the devs, that's why versions.json is managed by update.sh and doesn't require manual interference.

Personally I need to know the exact MariaDB version to decide whether I need to rebuild my image. Since I'm using the Dockerfile directly, I can't rely on MariaDB's REST API due to said delays, because the REST API might yield a new version that wasn't released in this repo yet. The same is true when pulling the image from Docker Hub to examine the image (like accessing the version label, or the MARIADB_VERSION env variable). All these variants don't provide me the info I need ("what version is built by this Dockerfile"), but somewhat similar, yet different info. A working alternative would be to build the container and then examine the version label, but that would make no sense since I'm about to decide whether I need to build the container - if not, it would have been a total waste of energy. So, right now I'm using the following sed snippet to read the version from the Dockerfile (okay, the regex actually looks a little different, but it's the same principle) - it works, but definitely is no nice solution and very prone to changes:

$ sed -ne 's/^ARG MARIADB_VERSION=\([0-9]*:\)\?\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\([+~-].*\)\?$/\2.\3.\4/p' "./vendor/10.5/Dockerfile"
10.5.21

Adding versions.json just makes these things way easier, simply because update.sh already has all the information needed, it just needs to dump it somewhere.

@grooverdan grooverdan merged commit 041f5df into MariaDB:master Jun 19, 2023
@grooverdan
Copy link
Member

Thank for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants