mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore(coderd/database): remove deprecated db2sdk.List(Lazy)? methods (#21902)
Removes deprecated methods db2sdk.List and db2sdk.ListLazy.
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
|
||||
"cdr.dev/slog/v3"
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/coderd/database/db2sdk"
|
||||
"github.com/coder/coder/v2/coderd/database/dbauthz"
|
||||
"github.com/coder/coder/v2/coderd/runtimeconfig"
|
||||
"github.com/coder/coder/v2/coderd/util/ptr"
|
||||
@@ -202,7 +201,7 @@ func (s AGPLIDPSync) SyncGroups(ctx context.Context, db database.Store, user dat
|
||||
// determine if we have to do any group updates to sync the user's
|
||||
// state.
|
||||
existingGroups := userOrgs[orgID]
|
||||
existingGroupsTyped := db2sdk.List(existingGroups, func(f database.GetGroupsRow) ExpectedGroup {
|
||||
existingGroupsTyped := slice.List(existingGroups, func(f database.GetGroupsRow) ExpectedGroup {
|
||||
return ExpectedGroup{
|
||||
OrganizationID: orgID,
|
||||
GroupID: &f.Group.ID,
|
||||
|
||||
@@ -15,13 +15,13 @@ import (
|
||||
"cdr.dev/slog/v3/sloggers/slogtest"
|
||||
"github.com/coder/coder/v2/coderd/coderdtest"
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/coderd/database/db2sdk"
|
||||
"github.com/coder/coder/v2/coderd/database/dbauthz"
|
||||
"github.com/coder/coder/v2/coderd/database/dbgen"
|
||||
"github.com/coder/coder/v2/coderd/database/dbtestutil"
|
||||
"github.com/coder/coder/v2/coderd/idpsync"
|
||||
"github.com/coder/coder/v2/coderd/runtimeconfig"
|
||||
"github.com/coder/coder/v2/coderd/util/ptr"
|
||||
"github.com/coder/coder/v2/coderd/util/slice"
|
||||
"github.com/coder/coder/v2/codersdk"
|
||||
"github.com/coder/coder/v2/testutil"
|
||||
)
|
||||
@@ -590,7 +590,7 @@ func TestApplyGroupDifference(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// assert
|
||||
found := db2sdk.List(userGroups, func(g database.GetGroupsRow) uuid.UUID {
|
||||
found := slice.List(userGroups, func(g database.GetGroupsRow) uuid.UUID {
|
||||
return g.Group.ID
|
||||
})
|
||||
|
||||
@@ -910,14 +910,14 @@ func (o *orgGroupAssert) Assert(t *testing.T, orgID uuid.UUID, db database.Store
|
||||
})
|
||||
|
||||
if len(o.ExpectedGroupNames) > 0 {
|
||||
found := db2sdk.List(userGroups, func(g database.GetGroupsRow) string {
|
||||
found := slice.List(userGroups, func(g database.GetGroupsRow) string {
|
||||
return g.Group.Name
|
||||
})
|
||||
require.ElementsMatch(t, o.ExpectedGroupNames, found, "user groups by name")
|
||||
require.Len(t, o.ExpectedGroups, 0, "ExpectedGroups should be empty")
|
||||
} else {
|
||||
// Check by ID, recommended
|
||||
found := db2sdk.List(userGroups, func(g database.GetGroupsRow) uuid.UUID {
|
||||
found := slice.List(userGroups, func(g database.GetGroupsRow) uuid.UUID {
|
||||
return g.Group.ID
|
||||
})
|
||||
require.ElementsMatch(t, o.ExpectedGroups, found, "user groups")
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
"cdr.dev/slog/v3"
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/coderd/database/db2sdk"
|
||||
"github.com/coder/coder/v2/coderd/database/dbauthz"
|
||||
"github.com/coder/coder/v2/coderd/database/dbtime"
|
||||
"github.com/coder/coder/v2/coderd/runtimeconfig"
|
||||
@@ -107,7 +106,7 @@ func (s AGPLIDPSync) SyncOrganizations(ctx context.Context, tx database.Store, u
|
||||
return xerrors.Errorf("failed to get user organizations: %w", err)
|
||||
}
|
||||
|
||||
existingOrgIDs := db2sdk.List(existingOrgs, func(org database.Organization) uuid.UUID {
|
||||
existingOrgIDs := slice.List(existingOrgs, func(org database.Organization) uuid.UUID {
|
||||
return org.ID
|
||||
})
|
||||
|
||||
@@ -127,7 +126,7 @@ func (s AGPLIDPSync) SyncOrganizations(ctx context.Context, tx database.Store, u
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to get expected organizations: %w", err)
|
||||
}
|
||||
finalExpected = db2sdk.List(expectedOrganizations, func(org database.Organization) uuid.UUID {
|
||||
finalExpected = slice.List(expectedOrganizations, func(org database.Organization) uuid.UUID {
|
||||
return org.ID
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ import (
|
||||
|
||||
"cdr.dev/slog/v3/sloggers/slogtest"
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/coderd/database/db2sdk"
|
||||
"github.com/coder/coder/v2/coderd/database/dbfake"
|
||||
"github.com/coder/coder/v2/coderd/database/dbgen"
|
||||
"github.com/coder/coder/v2/coderd/database/dbtestutil"
|
||||
"github.com/coder/coder/v2/coderd/idpsync"
|
||||
"github.com/coder/coder/v2/coderd/runtimeconfig"
|
||||
"github.com/coder/coder/v2/coderd/util/slice"
|
||||
"github.com/coder/coder/v2/testutil"
|
||||
)
|
||||
|
||||
@@ -173,7 +173,7 @@ func TestSyncOrganizations(t *testing.T) {
|
||||
|
||||
// Verify the user only exists in 2 orgs. The one they stayed, and the one they
|
||||
// joined.
|
||||
inIDs := db2sdk.List(orgs, func(org database.Organization) uuid.UUID {
|
||||
inIDs := slice.List(orgs, func(org database.Organization) uuid.UUID {
|
||||
return org.ID
|
||||
})
|
||||
require.ElementsMatch(t, []uuid.UUID{stays.Org.ID, joins.Org.ID}, inIDs)
|
||||
|
||||
Reference in New Issue
Block a user