From 743777035282934a2f58e15f070250016b9c05fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 23 Sep 2024 15:12:40 +0200 Subject: [PATCH] composer: don't create RepoRegistry using reporegistry.New() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `reporegistry.New()` has been enhanced to return an error, in case there were no repositories loaded. This was to fix the situation in many unit tests, which were previously not loading any repositories and silently not running any tests. This however broke our SaaS deployment, where we actually do not configure any repositories on the filesystem. As a result, osbuild-composer started to fail on it. Workaround this situation in osbuild-composer by reverting to the old behavior by loading the repo configs separately and then using the loaded repos (which could be empty map) to initialize the RepoRegistry. Signed-off-by: Tomáš Hozza --- cmd/osbuild-composer/composer.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/osbuild-composer/composer.go b/cmd/osbuild-composer/composer.go index 49f6a02199..485248d6fe 100644 --- a/cmd/osbuild-composer/composer.go +++ b/cmd/osbuild-composer/composer.go @@ -77,10 +77,11 @@ func NewComposer(config *ComposerConfigFile, stateDir, cacheDir string) (*Compos return nil, fmt.Errorf("failed to configure distro aliases: %v", err) } - c.repos, err = reporegistry.New(repositoryConfigs) + repoConfigs, err := reporegistry.LoadAllRepositories(repositoryConfigs) if err != nil { return nil, fmt.Errorf("error loading repository definitions: %v", err) } + c.repos = reporegistry.NewFromDistrosRepoConfigs(repoConfigs) c.solver = dnfjson.NewBaseSolver(path.Join(c.cacheDir, "rpmmd")) c.solver.SetDNFJSONPath(c.config.DNFJson)