buildpacks / spec

Specification for Cloud Native Buildpacks
https://buildpacks.io
Apache License 2.0
250 stars 69 forks source link

Buildpack API inconsistency around naming/data-type of `targets.distros.version` field in `buildpack.toml` #401

Closed edmorley closed 3 months ago

edmorley commented 3 months ago

In Buildpack API 0.10, the concept of stacks was replaced by targets:

Part of the targets feature is the concept of distro names/versions.

For example, the spec currently gives an example buildpack.toml as:

[[targets]]
os = "<OS name>"
arch = "<architecture>"
variant = "<architecture variant>"
[[targets.distros]]
name = "<OS distribution name>"
version = "<OS distribution version>"

(from https://github.com/buildpacks/spec/blob/87dc65b9611f88349cead9676e22657349072c90/buildpack.md#buildpacktoml-toml)

And also gives a similar example here:

Tools reading `buildpack.toml` will translate any section that sets `stacks.id = "io.buildpacks.stacks.bionic"` to:

```toml
[[targets]]
os = "linux"
arch = "amd64"
[[targets.distros]]
name = "ubuntu"
version = "18.04"

(from https://github.com/buildpacks/spec/blob/87dc65b9611f88349cead9676e22657349072c90/buildpack.md#buildpacktoml-toml-stacks-array)

However, elsewhere in the spec, the `version` field has a different name, `versions`:

Each target in targets:

(from https://github.com/buildpacks/spec/blob/87dc65b9611f88349cead9676e22657349072c90/buildpack.md#targets-1)

It seems the original RFC used the name versions with data-type array: https://github.com/buildpacks/rfcs/blob/ce8991b3d739f763b8356ae8696ae582f18c4af6/text/0096-remove-stacks-mixins.md#base-image-metadata

...but that the field was renamed/changed to a string in this commit when the changes were added to the RFC: https://github.com/buildpacks/spec/pull/365/commits/8652ec5e492998e0233c7778b7217d8433f16663

And version is also what's used in the implementation: https://github.com/buildpacks/lifecycle/blob/cd50eb8848492eac9b58c56d060d7d47ac56c693/buildpack/bp_descriptor.go#L39-L43

As such, I think the version usages in the spec are what was intended, and we should standardise everything on that.

I'll open PRs against the spec. (And I'll also backport the changes to the RFC as part of the existing PR I have open for that: https://github.com/buildpacks/rfcs/pull/310)

cc @natalieparellano