Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #925

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions pkg/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ type ImageType interface {
// Returns the package set names safe to install custom packages via custom repositories.
PayloadPackageSets() []string

// Returns named arrays of package set names which should be depsolved in a chain.
PackageSetsChains() map[string][]string

// Returns the names of the stages that will produce the build output.
Exports() []string

Expand Down
57 changes: 1 addition & 56 deletions pkg/distro/distro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,61 +21,6 @@ import (
"github.com/stretchr/testify/require"
)

// Ensure that all package sets defined in the package set chains are defined for the image type
func TestImageType_PackageSetsChains(t *testing.T) {
thozza marked this conversation as resolved.
Show resolved Hide resolved
distroFactory := distrofactory.NewDefault()
distros := distro_test_common.ListTestedDistros(t)
for _, distroName := range distros {
d := distroFactory.GetDistro(distroName)
for _, archName := range d.ListArches() {
arch, err := d.GetArch(archName)
require.Nil(t, err)
for _, imageTypeName := range arch.ListImageTypes() {
t.Run(fmt.Sprintf("%s/%s/%s", distroName, archName, imageTypeName), func(t *testing.T) {
imageType, err := arch.GetImageType(imageTypeName)
require.Nil(t, err)

// set up bare minimum args for image type
var customizations *blueprint.Customizations
if imageType.Name() == "edge-simplified-installer" || imageType.Name() == "iot-simplified-installer" {
customizations = &blueprint.Customizations{
InstallationDevice: "/dev/null",
}
}
bp := blueprint.Blueprint{
Customizations: customizations,
}
options := distro.ImageOptions{
OSTree: &ostree.ImageOptions{
URL: "https://example.com", // required by some image types
},
}
manifest, _, err := imageType.Manifest(&bp, options, nil, 0)
require.NoError(t, err)
imagePkgSets := manifest.GetPackageSetChains()
for packageSetName := range imageType.PackageSetsChains() {
_, ok := imagePkgSets[packageSetName]
if !ok {
// in the new pipeline generation logic the name of the package
// set chains are taken from the pipelines and do not match the
// package set names.
// TODO: redefine package set chains to make this unneccesary
switch packageSetName {
case "packages":
_, ok = imagePkgSets["os"]
if !ok {
_, ok = imagePkgSets["ostree-tree"]
}
}
}
assert.Truef(t, ok, "package set %q defined in a package set chain is not present in the image package sets", packageSetName)
}
})
}
}
}
}

// Ensure all image types report the correct names for their pipelines.
// Each image type contains a list of build and payload pipelines. They are
// needed for knowing the names of pipelines from the static object without
Expand Down Expand Up @@ -583,7 +528,7 @@ func TestDistro_ManifestFIPSWarning(t *testing.T) {
distros := distro_test_common.ListTestedDistros(t)
for _, distroName := range distros {
// FIPS blueprint customization is not supported for RHEL 7 images
if distroName == "rhel-7" {
if strings.HasPrefix(distroName, "rhel-7") {
continue
}
d := distroFactory.GetDistro(distroName)
Expand Down
5 changes: 4 additions & 1 deletion pkg/distro/distro_test_common/distro_test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,5 +465,8 @@ func TestDistro_OSTreeOptions(t *testing.T, d distro.Distro) {
func ListTestedDistros(t *testing.T) []string {
testRepoRegistry, err := reporegistry.NewTestedDefault()
require.Nil(t, err)
return testRepoRegistry.ListDistros()
require.NotEmpty(t, testRepoRegistry)
distros := testRepoRegistry.ListDistros()
require.NotEmpty(t, distros)
return distros
}
4 changes: 0 additions & 4 deletions pkg/distro/fedora/imagetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ func (t *imageType) PayloadPackageSets() []string {
return []string{blueprintPkgsKey}
}

func (t *imageType) PackageSetsChains() map[string][]string {
return make(map[string][]string)
}

func (t *imageType) Exports() []string {
if len(t.exports) > 0 {
return t.exports
Expand Down
4 changes: 0 additions & 4 deletions pkg/distro/rhel/imagetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ func (t *ImageType) PayloadPackageSets() []string {
return []string{BlueprintPkgsKey}
}

func (t *ImageType) PackageSetsChains() map[string][]string {
return nil
}

func (t *ImageType) Exports() []string {
if len(t.exports) > 0 {
return t.exports
Expand Down
6 changes: 0 additions & 6 deletions pkg/distro/test_distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,6 @@ func (t *TestImageType) PayloadPackageSets() []string {
return []string{blueprintPkgsKey}
}

func (t *TestImageType) PackageSetsChains() map[string][]string {
return map[string][]string{
osPkgsKey: {osPkgsKey, blueprintPkgsKey},
}
}

func (t *TestImageType) Exports() []string {
return distro.ExportsFallback()
}
Expand Down
13 changes: 12 additions & 1 deletion pkg/reporegistry/reporegistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package reporegistry

import (
"fmt"
"path/filepath"
"runtime"

"github.com/osbuild/images/pkg/distroidparser"
"github.com/osbuild/images/pkg/rpmmd"
Expand All @@ -21,14 +23,23 @@ func New(repoConfigPaths []string) (*RepoRegistry, error) {
if err != nil {
return nil, err
}
if len(repositories) == 0 {
return nil, fmt.Errorf("no repositories found in the given paths: %v", repoConfigPaths)
}

return &RepoRegistry{repositories}, nil
}

// NewTestedDefault returns a new RepoRegistry instance with the data
// loaded from the default test repositories
func NewTestedDefault() (*RepoRegistry, error) {
testReposPath := []string{"./test/data"}
_, callerSrc, _, ok := runtime.Caller(0)
var testReposPath []string
if !ok {
testReposPath = append(testReposPath, "../../test/data")
} else {
testReposPath = append(testReposPath, filepath.Join(filepath.Dir(callerSrc), "../../test/data"))
}
return New(testReposPath)
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/reporegistry/reporegistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,10 @@ func TestInvalidReposByArchName(t *testing.T) {
})
}
}

func Test_NewTestedDefault(t *testing.T) {
rr, err := NewTestedDefault()
assert.Nil(t, err)
assert.NotNil(t, rr)
assert.NotEmpty(t, rr.ListDistros())
}
Loading