composer: don't create RepoRegistry using reporegistry.New()

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 <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2024-09-23 15:12:40 +02:00 committed by Tomáš Hozza
parent f001c05157
commit 7437770352

View file

@ -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)