Repository: osbuild/osbuild-composer
Pull request #268 (2020-03-02 23:08:17)

Minor cleanup in distro package
See individual commits. Tried to follow golang conventions a bit more: renaming a function, returning errors instead of panicking in a library, etc.


Patch:
diff --git a/cmd/osbuild-composer/main.go b/cmd/osbuild-composer/main.go
index 4aadf84f2..5dbe566cd 100644
--- a/cmd/osbuild-composer/main.go
+++ b/cmd/osbuild-composer/main.go
@@ -80,7 +80,11 @@ func main() {
 	}
 
 	rpm := rpmmd.NewRPMMD(path.Join(cacheDirectory, "rpmmd"))
-	distros := distro.NewRegistry([]string{"/etc/osbuild-composer", "/usr/share/osbuild-composer"})
+
+	distros, err := distro.NewDefaultRegistry([]string{"/etc/osbuild-composer", "/usr/share/osbuild-composer"})
+	if err != nil {
+		log.Fatalf("Error loading distros: %v", err)
+	}
 
 	distribution, err := distros.FromHost()
 	if err != nil {
diff --git a/cmd/osbuild-pipeline/main.go b/cmd/osbuild-pipeline/main.go
index b95343d2d..4349e16d1 100644
--- a/cmd/osbuild-pipeline/main.go
+++ b/cmd/osbuild-pipeline/main.go
@@ -64,7 +64,11 @@ func main() {
 		}
 	}
 
-	distros := distro.NewRegistry([]string{"."})
+	distros, err := distro.NewDefaultRegistry([]string{"."})
+	if err != nil {
+		panic(err)
+	}
+
 	d := distros.GetDistro(distroArg)
 	if d == nil {
 		panic("unknown distro: " + distroArg)
diff --git a/internal/distro/distro.go b/internal/distro/distro.go
index 56432f211..a9d14d686 100644
--- a/internal/distro/distro.go
+++ b/internal/distro/distro.go
@@ -3,6 +3,7 @@ package distro
 import (
 	"bufio"
 	"errors"
+	"fmt"
 	"io"
 	"os"
 	"strings"
@@ -70,52 +71,43 @@ type Registry struct {
 	distros map[common.Distribution]Distro
 }
 
-func WithSingleDistro(dist Distro) *Registry {
+func NewRegistry(distros ...Distro) (*Registry, error) {
 	reg := &Registry{
 		distros: make(map[common.Distribution]Distro),
 	}
-	reg.register(dist)
-	return reg
+	for _, distro := range distros {
+		distroTag := distro.Distribution()
+		if _, exists := reg.distros[distroTag]; exists {
+			return nil, fmt.Errorf("NewRegistry: passed two distros with the same name: %s", distro.Name())
+		}
+		reg.distros[distroTag] = distro
+	}
+	return reg, nil
 }
 
-func NewRegistry(confPaths []string) *Registry {
-	distros := &Registry{
-		distros: make(map[common.Distribution]Distro),
-	}
-	f30 := fedora30.New(confPaths)
-	if f30 == nil {
-		panic("Attempt to register Fedora 30 failed")
-	}
-	distros.register(f30)
-	f31 := fedora31.New(confPaths)
-	if f31 == nil {
-		panic("Attempt to register Fedora 31 failed")
+// Create a new Registry containing all known distros.
+func NewDefaultRegistry(confPaths []string) (*Registry, error) {
+	f30, err := fedora30.New(confPaths)
+	if err != nil {
+		return nil, fmt.Errorf("error loading fedora30: %v", err)
 	}
-	distros.register(f31)
-	f32 := fedora32.New(confPaths)
-	if f32 == nil {
-		panic("Attempt to register Fedora 32 failed")
+	f31, err := fedora31.New(confPaths)
+	if err != nil {
+		return nil, fmt.Errorf("error loading fedora31: %v", err)
 	}
-	distros.register(f32)
-	el81 := rhel81.New(confPaths)
-	if el81 == nil {
-		panic("Attempt to register RHEL 8.1 failed")
+	f32, err := fedora32.New(confPaths)
+	if err != nil {
+		return nil, fmt.Errorf("error loading fedora32: %v", err)
 	}
-	distros.register(el81)
-	el82 := rhel82.New(confPaths)
-	if el82 == nil {
-		panic("Attempt to register RHEL 8.2 failed")
+	el81, err := rhel81.New(confPaths)
+	if err != nil {
+		return nil, fmt.Errorf("error loading rhel81: %v", err)
 	}
-	distros.register(el82)
-	return distros
-}
-
-func (r *Registry) register(distro Distro) {
-	distroTag := distro.Distribution()
-	if _, exists := r.distros[distroTag]; exists {
-		panic("a distro with this name already exists: " + distro.Name())
+	el82, err := rhel82.New(confPaths)
+	if err != nil {
+		return nil, fmt.Errorf("error loading rhel82: %v", err)
 	}
-	r.distros[distroTag] = distro
+	return NewRegistry(f30, f31, f32, el81, el82)
 }
 
 func (r *Registry) GetDistro(name string) Distro {
diff --git a/internal/distro/fedora30/distro.go b/internal/distro/fedora30/distro.go
index 7387c95ee..c38130c2c 100644
--- a/internal/distro/fedora30/distro.go
+++ b/internal/distro/fedora30/distro.go
@@ -2,6 +2,7 @@ package fedora30
 
 import (
 	"errors"
+	"fmt"
 	"log"
 	"sort"
 	"strconv"
@@ -46,7 +47,7 @@ type output struct {
 const Distro = common.Fedora30
 const ModulePlatformID = "platform:f30"
 
-func New(confPaths []string) *Fedora30 {
+func New(confPaths []string) (*Fedora30, error) {
 	const GigaByte = 1024 * 1024 * 1024
 
 	r := Fedora30{
@@ -65,8 +66,7 @@ func New(confPaths []string) *Fedora30 {
 
 	repoMap, err := rpmmd.LoadRepositories(confPaths, r.Name())
 	if err != nil {
-		log.Printf("Could not load repository data for %s: %s", r.Name(), err.Error())
-		return nil
+		return nil, fmt.Errorf("Could not load repository data for %s: %s", r.Name(), err.Error())
 	}
 
 	repos, exists := repoMap["x86_64"]
@@ -307,7 +307,7 @@ func New(confPaths []string) *Fedora30 {
 		},
 	}
 
-	return &r
+	return &r, nil
 }
 
 func (r *Fedora30) Name() string {
diff --git a/internal/distro/fedora31/distro.go b/internal/distro/fedora31/distro.go
index 52eff793f..23e7bd36f 100644
--- a/internal/distro/fedora31/distro.go
+++ b/internal/distro/fedora31/distro.go
@@ -2,6 +2,7 @@ package fedora31
 
 import (
 	"errors"
+	"fmt"
 	"log"
 	"sort"
 	"strconv"
@@ -46,7 +47,7 @@ type output struct {
 const Distro = common.Fedora31
 const ModulePlatformID = "platform:f31"
 
-func New(confPaths []string) *Fedora31 {
+func New(confPaths []string) (*Fedora31, error) {
 	const GigaByte = 1024 * 1024 * 1024
 
 	r := Fedora31{
@@ -65,8 +66,7 @@ func New(confPaths []string) *Fedora31 {
 
 	repoMap, err := rpmmd.LoadRepositories(confPaths, r.Name())
 	if err != nil {
-		log.Printf("Could not load repository data for %s: %s", r.Name(), err.Error())
-		return nil
+		return nil, fmt.Errorf("Could not load repository data for %s: %s", r.Name(), err.Error())
 	}
 
 	repos, exists := repoMap["x86_64"]
@@ -307,7 +307,7 @@ func New(confPaths []string) *Fedora31 {
 		},
 	}
 
-	return &r
+	return &r, nil
 }
 
 func (r *Fedora31) Name() string {
diff --git a/internal/distro/fedora32/distro.go b/internal/distro/fedora32/distro.go
index d2a7b737e..56d237d48 100644
--- a/internal/distro/fedora32/distro.go
+++ b/internal/distro/fedora32/distro.go
@@ -2,6 +2,7 @@ package fedora32
 
 import (
 	"errors"
+	"fmt"
 	"log"
 	"sort"
 	"strconv"
@@ -46,7 +47,7 @@ type output struct {
 const Distro = common.Fedora32
 const ModulePlatformID = "platform:f32"
 
-func New(confPaths []string) *Fedora32 {
+func New(confPaths []string) (*Fedora32, error) {
 	const GigaByte = 1024 * 1024 * 1024
 
 	r := Fedora32{
@@ -65,8 +66,7 @@ func New(confPaths []string) *Fedora32 {
 
 	repoMap, err := rpmmd.LoadRepositories(confPaths, r.Name())
 	if err != nil {
-		log.Printf("Could not load repository data for %s: %s", r.Name(), err.Error())
-		return nil
+		return nil, fmt.Errorf("Could not load repository data for %s: %s", r.Name(), err.Error())
 	}
 
 	repos, exists := repoMap["x86_64"]
@@ -307,7 +307,7 @@ func New(confPaths []string) *Fedora32 {
 		},
 	}
 
-	return &r
+	return &r, nil
 }
 
 func (r *Fedora32) Name() string {
diff --git a/internal/distro/rhel81/distro.go b/internal/distro/rhel81/distro.go
index c4129b58d..397eadb22 100644
--- a/internal/distro/rhel81/distro.go
+++ b/internal/distro/rhel81/distro.go
@@ -2,6 +2,7 @@ package rhel81
 
 import (
 	"errors"
+	"fmt"
 	"log"
 	"sort"
 	"strconv"
@@ -47,7 +48,7 @@ type output struct {
 const Distro = common.RHEL81
 const ModulePlatformID = "platform:el8"
 
-func New(confPaths []string) *RHEL81 {
+func New(confPaths []string) (*RHEL81, error) {
 	const GigaByte = 1024 * 1024 * 1024
 
 	r := RHEL81{
@@ -70,8 +71,7 @@ func New(confPaths []string) *RHEL81 {
 
 	repoMap, err := rpmmd.LoadRepositories(confPaths, r.Name())
 	if err != nil {
-		log.Printf("Could not load repository data for %s: %s", r.Name(), err.Error())
-		return nil
+		return nil, fmt.Errorf("Could not load repository data for %s: %s", r.Name(), err.Error())
 	}
 
 	repos, exists := repoMap["x86_64"]
@@ -446,7 +446,7 @@ func New(confPaths []string) *RHEL81 {
 		},
 	}
 
-	return &r
+	return &r, nil
 }
 
 func (r *RHEL81) Name() string {
diff --git a/internal/distro/rhel82/distro.go b/internal/distro/rhel82/distro.go
index 657e97fb2..934a1dd9e 100644
--- a/internal/distro/rhel82/distro.go
+++ b/internal/distro/rhel82/distro.go
@@ -2,6 +2,7 @@ package rhel82
 
 import (
 	"errors"
+	"fmt"
 	"log"
 	"sort"
 	"strconv"
@@ -47,7 +48,7 @@ type output struct {
 const Distro = common.RHEL82
 const ModulePlatformID = "platform:el8"
 
-func New(confPaths []string) *RHEL82 {
+func New(confPaths []string) (*RHEL82, error) {
 	const GigaByte = 1024 * 1024 * 1024
 
 	r := RHEL82{
@@ -70,8 +71,7 @@ func New(confPaths []string) *RHEL82 {
 
 	repoMap, err := rpmmd.LoadRepositories(confPaths, r.Name())
 	if err != nil {
-		log.Printf("Could not load repository data for %s: %s", r.Name(), err.Error())
-		return nil
+		return nil, fmt.Errorf("Could not load repository data for %s: %s", r.Name(), err.Error())
 	}
 
 	repos, exists := repoMap["x86_64"]
@@ -446,7 +446,7 @@ func New(confPaths []string) *RHEL82 {
 		},
 	}
 
-	return &r
+	return &r, nil
 }
 
 func (r *RHEL82) Name() string {
diff --git a/internal/jobqueue/job.go b/internal/jobqueue/job.go
index 5e63ada4a..de3f91eaa 100644
--- a/internal/jobqueue/job.go
+++ b/internal/jobqueue/job.go
@@ -46,7 +46,11 @@ func (e *TargetsError) Error() string {
 }
 
 func (job *Job) Run(uploader LocalTargetUploader) (*common.ComposeResult, error) {
-	distros := distro.NewRegistry([]string{"/etc/osbuild-composer", "/usr/share/osbuild-composer"})
+	distros, err := distro.NewDefaultRegistry([]string{"/etc/osbuild-composer", "/usr/share/osbuild-composer"})
+	if err != nil {
+		return nil, fmt.Errorf("error loading distros: %v", err)
+	}
+
 	d := distros.GetDistro(job.Distro)
 	if d == nil {
 		return nil, fmt.Errorf("unknown distro: %s", job.Distro)
diff --git a/internal/mocks/distro/distro_mock.go b/internal/mocks/distro/distro_mock.go
index 178ee3e93..ce65d5005 100644
--- a/internal/mocks/distro/distro_mock.go
+++ b/internal/mocks/distro/distro_mock.go
@@ -5,10 +5,10 @@ import (
 	"github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
 )
 
-func NewRegistry() *distro.Registry {
+func NewDefaultRegistry() (*distro.Registry, error) {
 	ftest := fedoratest.New()
 	if ftest == nil {
 		panic("Attempt to register Fedora test failed")
 	}
-	return distro.WithSingleDistro(ftest)
+	return distro.NewRegistry(ftest)
 }
diff --git a/internal/mocks/rpmmd/fixtures.go b/internal/mocks/rpmmd/fixtures.go
index 7b8c2f7ca..34c17f77f 100644
--- a/internal/mocks/rpmmd/fixtures.go
+++ b/internal/mocks/rpmmd/fixtures.go
@@ -94,7 +94,7 @@ func createBaseStoreFixture() *store.Store {
 	}
 
 	d := test_distro.New()
-	r := distro_mock.NewRegistry()
+	r, _ := distro_mock.NewDefaultRegistry()
 	s := store.New(nil, d, *r)
 
 	s.Blueprints[bName] = b
@@ -191,7 +191,7 @@ func createStoreWithoutComposesFixture() *store.Store {
 	}
 
 	d := test_distro.New()
-	r := distro_mock.NewRegistry()
+	r, _ := distro_mock.NewDefaultRegistry()
 	s := store.New(nil, d, *r)
 
 	s.Blueprints[bName] = b


Test patch:
diff --git a/internal/distro/distro_test.go b/internal/distro/distro_test.go
index 26ae738a0..b81d81992 100644
--- a/internal/distro/distro_test.go
+++ b/internal/distro/distro_test.go
@@ -42,7 +42,10 @@ func TestDistro_Pipeline(t *testing.T) {
 			continue
 		}
 		t.Run(tt.Compose.OutputFormat, func(t *testing.T) {
-			distros := distro.NewRegistry([]string{"../.."})
+			distros, err := distro.NewDefaultRegistry([]string{"../.."})
+			if err != nil {
+				t.Fatal(err)
+			}
 			d := distros.GetDistro(tt.Compose.Distro)
 			if d == nil {
 				t.Errorf("unknown distro: %v", tt.Compose.Distro)
diff --git a/internal/distro/fedora30/distro_test.go b/internal/distro/fedora30/distro_test.go
index 1e6e69975..b9498fefe 100644
--- a/internal/distro/fedora30/distro_test.go
+++ b/internal/distro/fedora30/distro_test.go
@@ -4,7 +4,7 @@ import (
 	"reflect"
 	"testing"
 
-	"github.com/osbuild/osbuild-composer/internal/distro"
+	"github.com/osbuild/osbuild-composer/internal/distro/fedora30"
 )
 
 func TestListOutputFormats(t *testing.T) {
@@ -19,8 +19,11 @@ func TestListOutputFormats(t *testing.T) {
 		"vmdk",
 	}
 
-	distros := distro.NewRegistry([]string{"../../../"})
-	f30 := distros.GetDistro("fedora-30")
+	f30, err := fedora30.New([]string{"../../../"})
+	if err != nil {
+		t.Fatal(err)
+	}
+
 	if got := f30.ListOutputFormats(); !reflect.DeepEqual(got, want) {
 		t.Errorf("ListOutputFormats() = %v, want %v", got, want)
 	}
@@ -93,8 +96,10 @@ func TestFilenameFromType(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			distros := distro.NewRegistry([]string{"../../../"})
-			f30 := distros.GetDistro("fedora-30")
+			f30, err := fedora30.New([]string{"../../../"})
+			if err != nil {
+				t.Fatal(err)
+			}
 			got, got1, err := f30.FilenameFromType(tt.args.outputFormat)
 			if (err != nil) != tt.wantErr {
 				t.Errorf("FilenameFromType() error = %v, wantErr %v", err, tt.wantErr)
diff --git a/internal/distro/fedora31/distro_test.go b/internal/distro/fedora31/distro_test.go
index b138f38fd..9ddf559ec 100644
--- a/internal/distro/fedora31/distro_test.go
+++ b/internal/distro/fedora31/distro_test.go
@@ -4,7 +4,7 @@ import (
 	"reflect"
 	"testing"
 
-	"github.com/osbuild/osbuild-composer/internal/distro"
+	"github.com/osbuild/osbuild-composer/internal/distro/fedora31"
 )
 
 func TestListOutputFormats(t *testing.T) {
@@ -19,8 +19,11 @@ func TestListOutputFormats(t *testing.T) {
 		"vmdk",
 	}
 
-	distros := distro.NewRegistry([]string{"../../../"})
-	f31 := distros.GetDistro("fedora-31")
+	f31, err := fedora31.New([]string{"../../../"})
+	if err != nil {
+		t.Fatal(err)
+	}
+
 	if got := f31.ListOutputFormats(); !reflect.DeepEqual(got, want) {
 		t.Errorf("ListOutputFormats() = %v, want %v", got, want)
 	}
@@ -93,8 +96,10 @@ func TestFilenameFromType(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			distros := distro.NewRegistry([]string{"../../../"})
-			f31 := distros.GetDistro("fedora-31")
+			f31, err := fedora31.New([]string{"../../../"})
+			if err != nil {
+				t.Fatal(err)
+			}
 			got, got1, err := f31.FilenameFromType(tt.args.outputFormat)
 			if (err != nil) != tt.wantErr {
 				t.Errorf("FilenameFromType() error = %v, wantErr %v", err, tt.wantErr)
diff --git a/internal/distro/fedora32/distro_test.go b/internal/distro/fedora32/distro_test.go
index 0ceb192ab..862d404c6 100644
--- a/internal/distro/fedora32/distro_test.go
+++ b/internal/distro/fedora32/distro_test.go
@@ -4,7 +4,7 @@ import (
 	"reflect"
 	"testing"
 
-	"github.com/osbuild/osbuild-composer/internal/distro"
+	"github.com/osbuild/osbuild-composer/internal/distro/fedora32"
 )
 
 func TestListOutputFormats(t *testing.T) {
@@ -19,8 +19,11 @@ func TestListOutputFormats(t *testing.T) {
 		"vmdk",
 	}
 
-	distros := distro.NewRegistry([]string{"../../../"})
-	f32 := distros.GetDistro("fedora-32")
+	f32, err := fedora32.New([]string{"../../../"})
+	if err != nil {
+		t.Fatal(err)
+	}
+
 	if got := f32.ListOutputFormats(); !reflect.DeepEqual(got, want) {
 		t.Errorf("ListOutputFormats() = %v, want %v", got, want)
 	}
@@ -93,8 +96,10 @@ func TestFilenameFromType(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			distros := distro.NewRegistry([]string{"../../../"})
-			f32 := distros.GetDistro("fedora-32")
+			f32, err := fedora32.New([]string{"../../../"})
+			if err != nil {
+				t.Fatal(err)
+			}
 			got, got1, err := f32.FilenameFromType(tt.args.outputFormat)
 			if (err != nil) != tt.wantErr {
 				t.Errorf("FilenameFromType() error = %v, wantErr %v", err, tt.wantErr)
diff --git a/internal/distro/rhel81/distro_test.go b/internal/distro/rhel81/distro_test.go
index 9950c1eb2..af4350f32 100644
--- a/internal/distro/rhel81/distro_test.go
+++ b/internal/distro/rhel81/distro_test.go
@@ -4,7 +4,7 @@ import (
 	"reflect"
 	"testing"
 
-	"github.com/osbuild/osbuild-composer/internal/distro"
+	"github.com/osbuild/osbuild-composer/internal/distro/rhel81"
 )
 
 func TestListOutputFormats(t *testing.T) {
@@ -19,9 +19,12 @@ func TestListOutputFormats(t *testing.T) {
 		"vmdk",
 	}
 
-	distros := distro.NewRegistry([]string{"../../../"})
-	rhel81 := distros.GetDistro("rhel-8.2")
-	if got := rhel81.ListOutputFormats(); !reflect.DeepEqual(got, want) {
+	el81, err := rhel81.New([]string{"../../../"})
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if got := el81.ListOutputFormats(); !reflect.DeepEqual(got, want) {
 		t.Errorf("ListOutputFormats() = %v, want %v", got, want)
 	}
 }
@@ -93,9 +96,11 @@ func TestFilenameFromType(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			distros := distro.NewRegistry([]string{"../../../"})
-			rhel81 := distros.GetDistro("rhel-8.2")
-			got, got1, err := rhel81.FilenameFromType(tt.args.outputFormat)
+			el81, err := rhel81.New([]string{"../../../"})
+			if err != nil {
+				t.Fatal(err)
+			}
+			got, got1, err := el81.FilenameFromType(tt.args.outputFormat)
 			if (err != nil) != tt.wantErr {
 				t.Errorf("FilenameFromType() error = %v, wantErr %v", err, tt.wantErr)
 				return
diff --git a/internal/distro/rhel82/distro_test.go b/internal/distro/rhel82/distro_test.go
index 3dea1259c..c30947665 100644
--- a/internal/distro/rhel82/distro_test.go
+++ b/internal/distro/rhel82/distro_test.go
@@ -4,7 +4,7 @@ import (
 	"reflect"
 	"testing"
 
-	"github.com/osbuild/osbuild-composer/internal/distro"
+	"github.com/osbuild/osbuild-composer/internal/distro/rhel82"
 )
 
 func TestListOutputFormats(t *testing.T) {
@@ -19,9 +19,12 @@ func TestListOutputFormats(t *testing.T) {
 		"vmdk",
 	}
 
-	distros := distro.NewRegistry([]string{"../../../"})
-	rhel82 := distros.GetDistro("rhel-8.2")
-	if got := rhel82.ListOutputFormats(); !reflect.DeepEqual(got, want) {
+	el82, err := rhel82.New([]string{"../../../"})
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if got := el82.ListOutputFormats(); !reflect.DeepEqual(got, want) {
 		t.Errorf("ListOutputFormats() = %v, want %v", got, want)
 	}
 }
@@ -93,9 +96,11 @@ func TestFilenameFromType(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			distros := distro.NewRegistry([]string{"../../../"})
-			rhel82 := distros.GetDistro("rhel-8.2")
-			got, got1, err := rhel82.FilenameFromType(tt.args.outputFormat)
+			el82, err := rhel82.New([]string{"../../../"})
+			if err != nil {
+				t.Fatal(err)
+			}
+			got, got1, err := el82.FilenameFromType(tt.args.outputFormat)
 			if (err != nil) != tt.wantErr {
 				t.Errorf("FilenameFromType() error = %v, wantErr %v", err, tt.wantErr)
 				return
diff --git a/internal/jobqueue/api_test.go b/internal/jobqueue/api_test.go
index 69a5e1bd1..0cdf77026 100644
--- a/internal/jobqueue/api_test.go
+++ b/internal/jobqueue/api_test.go
@@ -34,7 +34,10 @@ func TestBasic(t *testing.T) {
 
 	for _, c := range cases {
 		distroStruct := test_distro.New()
-		registry := distro_mock.NewRegistry()
+		registry, err := distro_mock.NewDefaultRegistry()
+		if err != nil {
+			t.Fatal(err)
+		}
 		api := jobqueue.New(nil, store.New(nil, distroStruct, *registry))
 
 		test.TestNonJsonRoute(t, api, false, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedResponse)
@@ -44,11 +47,14 @@ func TestBasic(t *testing.T) {
 func TestCreate(t *testing.T) {
 	id, _ := uuid.Parse("ffffffff-ffff-ffff-ffff-ffffffffffff")
 	distroStruct := test_distro.New()
-	registry := distro_mock.NewRegistry()
+	registry, err := distro_mock.NewDefaultRegistry()
+	if err != nil {
+		t.Fatal(err)
+	}
 	store := store.New(nil, distroStruct, *registry)
 	api := jobqueue.New(nil, store)
 
-	err := store.PushCompose(id, &blueprint.Blueprint{}, nil, nil, map[string]string{"test-repo": "test:foo"}, "x86_64", "qcow2", 0, nil)
+	err = store.PushCompose(id, &blueprint.Blueprint{}, nil, nil, map[string]string{"test-repo": "test:foo"}, "x86_64", "qcow2", 0, nil)
 	if err != nil {
 		t.Fatalf("error pushing compose: %v", err)
 	}
@@ -60,7 +66,10 @@ func TestCreate(t *testing.T) {
 func testUpdateTransition(t *testing.T, from, to string, expectedStatus int, expectedResponse string) {
 	id, _ := uuid.Parse("ffffffff-ffff-ffff-ffff-ffffffffffff")
 	distroStruct := test_distro.New()
-	registry := distro_mock.NewRegistry()
+	registry, err := distro_mock.NewDefaultRegistry()
+	if err != nil {
+		t.Fatal(err)
+	}
 	store := store.New(nil, distroStruct, *registry)
 	api := jobqueue.New(nil, store)
 
diff --git a/internal/rcm/api_test.go b/internal/rcm/api_test.go
index 1e0009d00..d29d96ffe 100644
--- a/internal/rcm/api_test.go
+++ b/internal/rcm/api_test.go
@@ -49,7 +49,10 @@ func TestBasicRcmAPI(t *testing.T) {
 		{"GET", "/v1/compose/7802c476-9cd1-41b7-ba81-43c1906bce73", `{"status":"RUNNING"}`, "application/json", http.StatusBadRequest, `{"error_reason":"Compose UUID does not exist"}`},
 	}
 
-	registry := distro_mock.NewRegistry()
+	registry, err := distro_mock.NewDefaultRegistry()
+	if err != nil {
+		t.Fatal(err)
+	}
 	distroStruct := fedoratest.New()
 	api := rcm.New(nil, store.New(nil, distroStruct, *registry), rpmmd_mock.NewRPMMDMock(rpmmd_mock.BaseFixture()))
 
@@ -74,7 +77,10 @@ func TestBasicRcmAPI(t *testing.T) {
 func TestSubmitCompose(t *testing.T) {
 	// Test the most basic use case: Submit a new job and get its status.
 	distroStruct := fedoratest.New()
-	registry := distro_mock.NewRegistry()
+	registry, err := distro_mock.NewDefaultRegistry()
+	if err != nil {
+		t.Fatal(err)
+	}
 	api := rcm.New(nil, store.New(nil, distroStruct, *registry), rpmmd_mock.NewRPMMDMock(rpmmd_mock.BaseFixture()))
 
 	var submit_reply struct {