reporegistry: introduce new distro.aliases file#1036
reporegistry: introduce new distro.aliases file#1036mvo5 wants to merge 2 commits intoosbuild:mainfrom
distro.aliases file#1036Conversation
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.
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.
| } | ||
| defer f.Close() | ||
| var aliases []struct { | ||
| Name string `json:"name"` |
There was a problem hiding this comment.
I'm not too happy with the names, ideas for better naming welcome here :)
|
Just a quick comment: I am not sure if
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). |
Oh, this super interesting - the only reason I am adding this is to avoid the symlink
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). |
|
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. |
|
Closing in favor of #1038 that hopefully addresses the concerns here. |
This commit introduces a new
distro.aliasesfile that replaces therole of the existing symlinks to provide an alias name for a distro.
The reason is that when using
go:embedsymlinks are not supportedand we have currently
centos-9.json -> centos-stream-9.jsoninour
osbuild-comopserdistro definitions.By moving them from symlinks to alias files we can start using
go:embedwhich is nice for the daemonless work, i.e. theimage-builderbinary will be self-contained and one can do:directly without any further configuration. It also solves how to
keep the default repository configuration between
osbuild-composerandimage-builder-cliin 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.