Use RepoRegistry in composer and Weldr API

Modify composer to use RepoRegistry, instead of loading the host
repositories, when initializing WeldrAPI.

Modify WeldrAPI to use RepoRegistry, instead of a map of repository
definitions. Make sure that the RepoRegistry method specific to image
type is used in Welder where appropriate. Specifically when depsolving a
Blueprint, which is used to build a specific image type. Update Weldr
API unit tests to reflect the change.

Add a new method to RepoRegistry, allowing to get list of repositories,
which should be used for building an image for a given architecture,
without specifying the exact image type. Add relevant unit tests.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
Tomas Hozza 2021-05-05 18:09:08 +02:00 committed by Ondřej Budai
parent fba9fe1072
commit aa6665ad01
6 changed files with 361 additions and 34 deletions

View file

@ -16,6 +16,7 @@ import (
"github.com/osbuild/osbuild-composer/internal/distro/test_distro"
rpmmd_mock "github.com/osbuild/osbuild-composer/internal/mocks/rpmmd"
"github.com/osbuild/osbuild-composer/internal/reporegistry"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
"github.com/osbuild/osbuild-composer/internal/weldr"
)
@ -49,9 +50,17 @@ func executeTests(m *testing.M) int {
if err != nil {
panic(err)
}
repos := []rpmmd.RepoConfig{{Name: "test-system-repo", BaseURL: "http://example.com/test/os/test_arch"}}
rr := reporegistry.NewFromDistrosRepoConfigs(rpmmd.DistrosRepoConfigs{
test_distro.TestDistroName: {
test_distro.TestArchName: {
{Name: "test-system-repo", BaseURL: "http://example.com/test/os/test_arch"},
},
},
})
logger := log.New(os.Stdout, "", 0)
api := weldr.New(rpm, arch, distro, repos, logger, fixture.Store, fixture.Workers, "")
api := weldr.New(rpm, arch, distro, rr, logger, fixture.Store, fixture.Workers, "")
server := http.Server{Handler: api}
defer server.Close()