From 0678d8ddfd592f4c504fc88fd2c922cfddef8289 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 6 Feb 2025 17:48:58 +0100 Subject: [PATCH] main: update for new reporegistry.New() api (c.f. pr#1179) This commit updates ibcli for the new API in images for the `reporegistry.New()`. The main incompatible change is that the `/repositories` part is not longer automatically added inside the library so we need to add it on the call-site. This needs https://github.com/osbuild/images/pull/1179 --- cmd/image-builder/repos.go | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/cmd/image-builder/repos.go b/cmd/image-builder/repos.go index bc238dc..4a2122c 100644 --- a/cmd/image-builder/repos.go +++ b/cmd/image-builder/repos.go @@ -2,21 +2,18 @@ package main import ( "io/fs" - "os" - "path/filepath" "github.com/osbuild/images/data/repositories" "github.com/osbuild/images/pkg/reporegistry" ) -// defaultDataDirs contains the default search paths to look for repository -// data. Note that the repositories are under a repositories/ sub-directory -// and contain a bunch of json files of the form "$distro_$version".json -// (but that is an implementation detail that the "images" library takes -// care of). +// defaultDataDirs contains the default search paths to look for +// repository data. They contain a bunch of json files of the form +// "$distro_$version".json (but that is an implementation detail that +// the "images" library takes care of). var defaultDataDirs = []string{ - "/etc/image-builder", - "/usr/share/image-builder", + "/etc/image-builder/repositories", + "/usr/share/image-builder/repositories", } var newRepoRegistry = func(dataDir string) (*reporegistry.RepoRegistry, error) { @@ -27,17 +24,5 @@ var newRepoRegistry = func(dataDir string) (*reporegistry.RepoRegistry, error) { dataDirs = defaultDataDirs } - // XXX: think about sharing this with reporegistry? - var fses []fs.FS - for _, d := range dataDirs { - fses = append(fses, os.DirFS(filepath.Join(d, "repositories"))) - } - fses = append(fses, repos.FS) - - // XXX: should we support disabling the build-ins somehow? - conf, err := reporegistry.LoadAllRepositoriesFromFS(fses) - if err != nil { - return nil, err - } - return reporegistry.NewFromDistrosRepoConfigs(conf), nil + return reporegistry.New(dataDirs, []fs.FS{repos.FS}) }