From 5906c554f69f295d1b98be1b54b2878f32a1d123 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 29 Jan 2025 22:08:24 +0100 Subject: [PATCH] cloudapi: update test to use repos from images This commit updates the cloudapi test that uses the real repositories to use the version of those from the "images" library. Composer no longer carries the default repos. Note that this can most likely be simplified once https://github.com/osbuild/images/pull/1179 is merged. --- internal/cloudapi/v2/compose_test.go | 10 ++++++---- osbuild-composer.spec | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/internal/cloudapi/v2/compose_test.go b/internal/cloudapi/v2/compose_test.go index f7f8dc7b7..bdb8ce1a8 100644 --- a/internal/cloudapi/v2/compose_test.go +++ b/internal/cloudapi/v2/compose_test.go @@ -1,8 +1,10 @@ package v2 import ( + "io/fs" "testing" + "github.com/osbuild/images/data/repositories" "github.com/osbuild/images/pkg/customizations/subscription" "github.com/osbuild/images/pkg/disk" "github.com/osbuild/images/pkg/distrofactory" @@ -811,9 +813,9 @@ func TestGetImageRequests_NoRepositories(t *testing.T) { Repositories: []Repository{}, }, } - // NOTE: current directory is the location of this file, back up so it can use ./repositories/ - rr, err := reporegistry.New([]string{"../../../"}) + reposConf, err := reporegistry.LoadAllRepositoriesFromFS([]fs.FS{repos.FS}) require.NoError(t, err) + rr := reporegistry.NewFromDistrosRepoConfigs(reposConf) got, err := request.GetImageRequests(distrofactory.NewDefault(), rr) assert.NoError(t, err) require.Len(t, got, 1) @@ -837,9 +839,9 @@ func TestGetImageRequests_BlueprintDistro(t *testing.T) { Distro: common.ToPtr("fedora-39"), }, } - // NOTE: current directory is the location of this file, back up so it can use ./repositories/ - rr, err := reporegistry.New([]string{"../../../"}) + reposConf, err := reporegistry.LoadAllRepositoriesFromFS([]fs.FS{repos.FS}) require.NoError(t, err) + rr := reporegistry.NewFromDistrosRepoConfigs(reposConf) got, err := request.GetImageRequests(distrofactory.NewDefault(), rr) assert.NoError(t, err) require.Len(t, got, 1) diff --git a/osbuild-composer.spec b/osbuild-composer.spec index 2ed46c8b7..691c099c6 100644 --- a/osbuild-composer.spec +++ b/osbuild-composer.spec @@ -172,7 +172,7 @@ cp -a repositories/centos-stream-%{centos}* %{buildroot}%{_datadir}/osb %if 0%{?rhel} # RHEL 10 supports building all RHEL versions %if 0%{?rhel} >= 10 -for REPO_FILE in $(ls vendor/github.com/osbuild/images/data/repositories/rhel-* | grep -v 'no-aux-key'); do +for REPO_FILE in $(ls vendor/github.com/osbuild/images/data/repositories/rhel-* ); do install -m 0644 -vp ${REPO_FILE} %{buildroot}%{_datadir}/osbuild-composer/repositories/$(basename ${REPO_FILE}) done @@ -183,13 +183,13 @@ done %else # All other RHEL versions support building for the same version -for REPO_FILE in $(ls vendor/github.com/osbuild/images/data/repositories/rhel-%{rhel}* | grep -v 'no-aux-key'); do +for REPO_FILE in $(ls vendor/github.com/osbuild/images/data/repositories/rhel-%{rhel}* ); do install -m 0644 -vp ${REPO_FILE} %{buildroot}%{_datadir}/osbuild-composer/repositories/$(basename ${REPO_FILE}) done # RHEL 9 supports building also for RHEL 8 %if 0%{?rhel} == 9 -for REPO_FILE in $(ls vendor/github.com/osbuild/images/data/repositories/rhel-8* | grep -v 'no-aux-key'); do +for REPO_FILE in $(ls vendor/github.com/osbuild/images/data/repositories/rhel-8* ); do install -m 0644 -vp ${REPO_FILE} %{buildroot}%{_datadir}/osbuild-composer/repositories/$(basename ${REPO_FILE}) done %endif