From 1345ca77fd36152223b7ec8576fe58b22c4cd93a Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sun, 22 Mar 2020 18:32:19 +0100 Subject: [PATCH] store: drop the distro registry This was now unused. Signed-off-by: Tom Gundersen --- cmd/osbuild-composer/main.go | 2 +- internal/jobqueue/api_test.go | 22 ++++------------------ internal/mocks/rpmmd/fixtures.go | 7 ++----- internal/rcm/api_test.go | 7 ++++--- internal/store/store.go | 12 +++++------- 5 files changed, 16 insertions(+), 34 deletions(-) diff --git a/cmd/osbuild-composer/main.go b/cmd/osbuild-composer/main.go index 1083e5d44..5e4b39c96 100644 --- a/cmd/osbuild-composer/main.go +++ b/cmd/osbuild-composer/main.go @@ -104,7 +104,7 @@ func main() { logger = log.New(os.Stdout, "", 0) } - store := store.New(&stateDir, *distros) + store := store.New(&stateDir) jobAPI := jobqueue.New(logger, store) weldrAPI := weldr.New(rpm, common.CurrentArch(), distribution, repoMap[common.CurrentArch()], logger, store) diff --git a/internal/jobqueue/api_test.go b/internal/jobqueue/api_test.go index 78ea7df38..be86055c5 100644 --- a/internal/jobqueue/api_test.go +++ b/internal/jobqueue/api_test.go @@ -4,8 +4,6 @@ import ( "net/http" "testing" - distro_mock "github.com/osbuild/osbuild-composer/internal/mocks/distro" - "github.com/osbuild/osbuild-composer/internal/blueprint" test_distro "github.com/osbuild/osbuild-composer/internal/distro/fedoratest" "github.com/osbuild/osbuild-composer/internal/jobqueue" @@ -34,11 +32,7 @@ func TestBasic(t *testing.T) { } for _, c := range cases { - registry, err := distro_mock.NewDefaultRegistry() - if err != nil { - t.Fatal(err) - } - api := jobqueue.New(nil, store.New(nil, *registry)) + api := jobqueue.New(nil, store.New(nil)) test.TestNonJsonRoute(t, api, false, c.Method, c.Path, c.Body, c.ExpectedStatus, c.ExpectedResponse) } @@ -47,14 +41,10 @@ func TestBasic(t *testing.T) { func TestCreate(t *testing.T) { id, _ := uuid.Parse("ffffffff-ffff-ffff-ffff-ffffffffffff") distroStruct := test_distro.New() - registry, err := distro_mock.NewDefaultRegistry() - if err != nil { - t.Fatal(err) - } - store := store.New(nil, *registry) + store := store.New(nil) api := jobqueue.New(nil, store) - err = store.PushCompose(distroStruct, id, &blueprint.Blueprint{}, nil, nil, nil, "x86_64", "qcow2", 0, nil) + err := store.PushCompose(distroStruct, id, &blueprint.Blueprint{}, nil, nil, nil, "x86_64", "qcow2", 0, nil) if err != nil { t.Fatalf("error pushing compose: %v", err) } @@ -66,11 +56,7 @@ 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, err := distro_mock.NewDefaultRegistry() - if err != nil { - t.Fatal(err) - } - store := store.New(nil, *registry) + store := store.New(nil) api := jobqueue.New(nil, store) if from != "VOID" { diff --git a/internal/mocks/rpmmd/fixtures.go b/internal/mocks/rpmmd/fixtures.go index 139e8dd05..e34ebee37 100644 --- a/internal/mocks/rpmmd/fixtures.go +++ b/internal/mocks/rpmmd/fixtures.go @@ -7,7 +7,6 @@ import ( "github.com/osbuild/osbuild-composer/internal/common" "github.com/osbuild/osbuild-composer/internal/compose" - distro_mock "github.com/osbuild/osbuild-composer/internal/mocks/distro" "github.com/google/uuid" "github.com/osbuild/osbuild-composer/internal/blueprint" @@ -93,8 +92,7 @@ func createBaseStoreFixture() *store.Store { }, } - r, _ := distro_mock.NewDefaultRegistry() - s := store.New(nil, *r) + s := store.New(nil) s.Blueprints[bName] = b s.Composes = map[uuid.UUID]compose.Compose{ @@ -189,8 +187,7 @@ func createStoreWithoutComposesFixture() *store.Store { Customizations: nil, } - r, _ := distro_mock.NewDefaultRegistry() - s := store.New(nil, *r) + s := store.New(nil) s.Blueprints[bName] = b diff --git a/internal/rcm/api_test.go b/internal/rcm/api_test.go index 95fe1c21e..f5c4fb2bc 100644 --- a/internal/rcm/api_test.go +++ b/internal/rcm/api_test.go @@ -3,12 +3,13 @@ package rcm_test import ( "bytes" "encoding/json" - "github.com/google/uuid" "net/http" "net/http/httptest" "regexp" "testing" + "github.com/google/uuid" + distro_mock "github.com/osbuild/osbuild-composer/internal/mocks/distro" rpmmd_mock "github.com/osbuild/osbuild-composer/internal/mocks/rpmmd" "github.com/osbuild/osbuild-composer/internal/rcm" @@ -52,7 +53,7 @@ func TestBasicRcmAPI(t *testing.T) { if err != nil { t.Fatal(err) } - api := rcm.New(nil, store.New(nil, *registry), rpmmd_mock.NewRPMMDMock(rpmmd_mock.BaseFixture()), registry) + api := rcm.New(nil, store.New(nil), rpmmd_mock.NewRPMMDMock(rpmmd_mock.BaseFixture()), registry) for _, c := range cases { resp := internalRequest(api, c.Method, c.Path, c.Body, c.ContentType) @@ -78,7 +79,7 @@ func TestSubmitCompose(t *testing.T) { if err != nil { t.Fatal(err) } - api := rcm.New(nil, store.New(nil, *registry), rpmmd_mock.NewRPMMDMock(rpmmd_mock.BaseFixture()), registry) + api := rcm.New(nil, store.New(nil), rpmmd_mock.NewRPMMDMock(rpmmd_mock.BaseFixture()), registry) var submit_reply struct { UUID uuid.UUID `json:"compose_id"` diff --git a/internal/store/store.go b/internal/store/store.go index b1fb08b5f..98539575d 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -42,11 +42,10 @@ type Store struct { BlueprintsChanges map[string]map[string]blueprint.Change `json:"changes"` BlueprintsCommits map[string][]string `json:"commits"` - mu sync.RWMutex // protects all fields - pendingJobs chan Job - stateChannel chan []byte - distroRegistry distro.Registry - stateDir *string + mu sync.RWMutex // protects all fields + pendingJobs chan Job + stateChannel chan []byte + stateDir *string } // A Job contains the information about a compose a worker needs to process it. @@ -107,7 +106,7 @@ func (e *NoLocalTargetError) Error() string { return e.message } -func New(stateDir *string, distroRegistryArg distro.Registry) *Store { +func New(stateDir *string) *Store { var s Store if stateDir != nil { @@ -141,7 +140,6 @@ func New(stateDir *string, distroRegistryArg distro.Registry) *Store { } s.pendingJobs = make(chan Job, 200) - s.distroRegistry = distroRegistryArg s.stateDir = stateDir if s.Blueprints == nil {