Move package set chain collation to the distro package and add repositories to the package sets while returning the package sets from their source, i.e., the ImageType.PackageSets() method. This also removes the concept of "base repositories". There are no longer repositories that are added implicitly to all package sets but instead each package set needs to specify *all* the repositories it will be depsolved against. This paves the way for the requirement we have for building RHEL 7 images with a RHEL 8 build root. The build root package set has to be depsolved against RHEL 8 repositories without any "base repos" included. This is now possible since package sets and repositories are explicitly associated from the start and there is no implicit global repository set. The change requires adding a list of PackageSet names to the core rpmmd.RepoConfig. In the cloud API, repositories that are limited to specific package sets already contain the correct package set names and these are now copied to the internal RepoConfig when converting types in genRepoConfig(). The user-specified repositories are only associated with the payload package sets like before.
101 lines
2 KiB
Go
101 lines
2 KiB
Go
package distro_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/osbuild/osbuild-composer/internal/distro"
|
|
"github.com/osbuild/osbuild-composer/internal/distro/distro_test_common"
|
|
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDistro_Manifest(t *testing.T) {
|
|
|
|
distro_test_common.TestDistro_Manifest(
|
|
t,
|
|
"../../test/data/manifests/",
|
|
"*",
|
|
distroregistry.NewDefault(),
|
|
false, // This test case does not check for changes in the imageType package sets!
|
|
"",
|
|
"",
|
|
)
|
|
}
|
|
|
|
var (
|
|
v1manifests = []string{
|
|
`{}`,
|
|
`
|
|
{
|
|
"sources": {
|
|
"org.osbuild.files": {
|
|
"urls": {}
|
|
}
|
|
},
|
|
"pipeline": {
|
|
"build": {
|
|
"pipeline": {
|
|
"stages": []
|
|
},
|
|
"runner": "org.osbuild.rhel84"
|
|
},
|
|
"stages": [],
|
|
"assembler": {
|
|
"name": "org.osbuild.qemu",
|
|
"options": {}
|
|
}
|
|
}
|
|
}`,
|
|
}
|
|
|
|
v2manifests = []string{
|
|
`{"version": "2"}`,
|
|
`
|
|
{
|
|
"version": "2",
|
|
"pipelines": [
|
|
{
|
|
"name": "build",
|
|
"runner": "org.osbuild.rhel84",
|
|
"stages": []
|
|
}
|
|
],
|
|
"sources": {
|
|
"org.osbuild.curl": {
|
|
"items": {}
|
|
}
|
|
}
|
|
}`,
|
|
}
|
|
)
|
|
|
|
func TestDistro_Version(t *testing.T) {
|
|
require := require.New(t)
|
|
expectedVersion := "1"
|
|
for idx, rawManifest := range v1manifests {
|
|
manifest := distro.Manifest(rawManifest)
|
|
detectedVersion, err := manifest.Version()
|
|
require.NoError(err, "Could not detect Manifest version for %d: %v", idx, err)
|
|
require.Equal(expectedVersion, detectedVersion, "in manifest %d", idx)
|
|
}
|
|
|
|
expectedVersion = "2"
|
|
for idx, rawManifest := range v2manifests {
|
|
manifest := distro.Manifest(rawManifest)
|
|
detectedVersion, err := manifest.Version()
|
|
require.NoError(err, "Could not detect Manifest version for %d: %v", idx, err)
|
|
require.Equal(expectedVersion, detectedVersion, "in manifest %d", idx)
|
|
}
|
|
|
|
{
|
|
manifest := distro.Manifest("")
|
|
_, err := manifest.Version()
|
|
require.Error(err, "Empty manifest did not return an error")
|
|
}
|
|
|
|
{
|
|
manifest := distro.Manifest("{")
|
|
_, err := manifest.Version()
|
|
require.Error(err, "Invalid manifest did not return an error")
|
|
}
|
|
}
|