osbuild / images

Image builder image definition library
Apache License 2.0
23 stars 52 forks source link

reporegistry: introduce new `distro.aliases` file #1036

Closed mvo5 closed 1 week ago

mvo5 commented 1 week ago

This commit introduces a new distro.aliases file that replaces the role of the existing symlinks to provide an alias name for a distro. The reason is that when using go:embed symlinks are not supported and we have currently centos-9.json -> centos-stream-9.json in our osbuild-comopser distro definitions.

By moving them from symlinks to alias files we can start using go:embed which is nice for the daemonless work, i.e. the image-builder binary will be self-contained and one can do:

$ go run github.com/osbuild/image-builder/cmd/image-builder --list-images

directly without any further configuration. It also solves how to keep the default repository configuration between osbuild-composer and image-builder-cli in sync.


reporegistry: remove duplication in LoadRepositories()

This commit removes some directory traversal duplication from LoadRepositories() on the expense of more "expensive" repo loading. The new code will just always load all repos and return the one matching the distro. The advantage of this approach is that when aliases are introduced there is only a single code path that needs changing.

thozza commented 1 week ago

Just a quick comment: I am not sure if distro.aliases is the best name since we already have distro aliases, and it is a different thing:

From my PoV, the ability to add a new repo config file or a symlink is a feature. I have yet to look at the code, but I would keep the option to redefine the alias for the user (ideally, not compiled into the binary).

mvo5 commented 1 week ago

Just a quick comment: I am not sure if distro.aliases is the best name since we already have distro aliases, and it is a different thing: [..]

Oh, this super interesting - the only reason I am adding this is to avoid the symlink centos-9.json -> centos-stream-9.json in the default repo configuration. If a distro_alias in the composer config fixes this equally nicely and we can drop the symlink none of the distro.alises support is needed.

From my PoV, the ability to add a new repo config file or a symlink is a feature. I have yet to look at the code, but I would keep the option to redefine the alias for the user (ideally, not compiled into the binary).

Both the ability to add new repo config, symlinks and to mask existing repos would be preserved. The goal of what I'm doing is strictly about making it easier to share the default/canonical repos from composer across multiple projects (image-builder-cli in my specific case).

mvo5 commented 1 week ago

Moving back to "draft" as it seems people do not really like this idea very much so far. So I will think a bit more what else we can do.

mvo5 commented 1 week ago

Closing in favor of https://github.com/osbuild/images/pull/1038 that hopefully addresses the concerns here.