Skip to content

Commit 82065eb

Browse files
refactor(api): make the domain types a public package
The domain types have lived in pkg/api/internal/types, with pkg/api re-exporting them through alias shims. That was scaffolding so the earlier splits (#1412, #1422, #1434, #1498) could move code without requalifying every caller at the same time. Those splits have landed, so the scaffolding comes down: types moves to pkg/api/types and callers name it directly. That leaves pkg/api owning just the database handle and the migrations, and the public admin and runtime packages no longer expose internal domain types in their signatures. This commit is purely refactoring and shouldn't change any behavior. Refs: #1375 Signed-off-by: Moustafa Moustafa <momousta@microsoft.com>
1 parent 386f9a8 commit 82065eb

96 files changed

Lines changed: 949 additions & 1217 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/pkg/api/actions.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

backend/pkg/api/actions_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ import (
44
"testing"
55

66
"github.com/stretchr/testify/assert"
7+
8+
"github.com/flatcar/nebraska/backend/pkg/api/types"
79
)
810

911
func TestAddFlatcarAction(t *testing.T) {
1012
a := newForTest(t)
1113
defer a.Close()
1214
as := adminSvc(a)
1315

14-
tTeam, _ := as.AddTeam(&Team{Name: "test_team"})
15-
tApp, _ := as.AddApp(&Application{Name: "test_app", TeamID: tTeam.ID})
16-
tPkg, _ := as.AddPackage(&Package{Type: PkgTypeFlatcar, URL: "http://sample.url/pkg", Version: "12.1.0", ApplicationID: tApp.ID})
16+
tTeam, _ := as.AddTeam(&types.Team{Name: "test_team"})
17+
tApp, _ := as.AddApp(&types.Application{Name: "test_app", TeamID: tTeam.ID})
18+
tPkg, _ := as.AddPackage(&types.Package{Type: types.PkgTypeFlatcar, URL: "http://sample.url/pkg", Version: "12.1.0", ApplicationID: tApp.ID})
1719

18-
flatcarAction, err := as.AddFlatcarAction(&FlatcarAction{Event: "postinstall", Sha256: "fsdkjjfghsdakjfgaksdjfasd", PackageID: tPkg.ID})
20+
flatcarAction, err := as.AddFlatcarAction(&types.FlatcarAction{Event: "postinstall", Sha256: "fsdkjjfghsdakjfgaksdjfasd", PackageID: tPkg.ID})
1921
assert.NoError(t, err)
2022

2123
flatcarActionX, err := a.GetFlatcarAction(tPkg.ID)

backend/pkg/api/activity.go

Lines changed: 0 additions & 8 deletions
This file was deleted.

backend/pkg/api/admin/actions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package admin
33
import (
44
"github.com/doug-martin/goqu/v9"
55

6-
"github.com/flatcar/nebraska/backend/pkg/api/internal/types"
6+
"github.com/flatcar/nebraska/backend/pkg/api/types"
77
)
88

99
// AddFlatcarAction registers the provided Omaha Flatcar action.

backend/pkg/api/admin/activity_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"gopkg.in/guregu/null.v4"
99

1010
"github.com/flatcar/nebraska/backend/pkg/api"
11-
"github.com/flatcar/nebraska/backend/pkg/api/internal/types"
11+
"github.com/flatcar/nebraska/backend/pkg/api/types"
1212
)
1313

1414
// TestAdminActivityRouting verifies that the admin-side activity writer
@@ -42,7 +42,7 @@ func TestAdminActivityRouting(t *testing.T) {
4242
assert.Equal(t, 0, runtimeCount, "admin writer must not write to the runtime activity table")
4343

4444
// Checking the admin activity is visible through the GetActivity as well.
45-
entries, err := a.GetActivity(tTeam.ID, api.ActivityQueryParams{AppID: tApp.ID})
45+
entries, err := a.GetActivity(tTeam.ID, types.ActivityQueryParams{AppID: tApp.ID})
4646
require.NoError(t, err)
4747
require.Len(t, entries, 1)
4848
assert.Equal(t, types.ActivityChannelPackageUpdated, entries[0].Class, "admin activity must be visible through GetActivity/all_activity")

backend/pkg/api/admin/applications.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/doug-martin/goqu/v9"
88
"gopkg.in/guregu/null.v4"
99

10-
"github.com/flatcar/nebraska/backend/pkg/api/internal/types"
10+
"github.com/flatcar/nebraska/backend/pkg/api/types"
1111
)
1212

1313
// AddApp registers the provided application.

backend/pkg/api/admin/channels.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package admin
33
import (
44
"github.com/doug-martin/goqu/v9"
55

6-
"github.com/flatcar/nebraska/backend/pkg/api/internal/types"
6+
"github.com/flatcar/nebraska/backend/pkg/api/types"
77
)
88

99
// AddChannel registers the provided channel.

backend/pkg/api/admin/groups.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/doug-martin/goqu/v9"
77
"github.com/google/uuid"
88

9-
"github.com/flatcar/nebraska/backend/pkg/api/internal/types"
9+
"github.com/flatcar/nebraska/backend/pkg/api/types"
1010
)
1111

1212
// AddGroup registers the provided group.

backend/pkg/api/admin/packages.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/jmoiron/sqlx"
1010

1111
"github.com/flatcar/nebraska/backend/pkg/api/internal/dbreads"
12-
"github.com/flatcar/nebraska/backend/pkg/api/internal/types"
12+
"github.com/flatcar/nebraska/backend/pkg/api/types"
1313
)
1414

1515
// checkMatchingArch returns an error if the arch does not match the channels

backend/pkg/api/admin/packages_floors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/doug-martin/goqu/v9"
77
"gopkg.in/guregu/null.v4"
88

9-
"github.com/flatcar/nebraska/backend/pkg/api/internal/types"
9+
"github.com/flatcar/nebraska/backend/pkg/api/types"
1010
)
1111

1212
// AddChannelPackageFloor marks a package as a floor for a specific channel

0 commit comments

Comments
 (0)