Skip to content

Commit 37eb60d

Browse files
committed
gen + lint
1 parent 52bad0b commit 37eb60d

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

coderd/database/queries.sql.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/idpsync/organization.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,23 @@ func (s AGPLIDPSync) SyncOrganizations(ctx context.Context, tx database.Store, u
111111
return org.ID
112112
})
113113

114-
expectedOrganizations, err := tx.GetOrganizations(ctx, database.GetOrganizationsParams{
115-
IDs: expectedOrgIDs,
116-
// Do not include deleted organizations
117-
Deleted: false,
118-
})
119-
if err != nil {
120-
return xerrors.Errorf("failed to get expected organizations: %w", err)
114+
// finalExpected is the final set of org ids the user is expected to be in.
115+
// Deleted orgs are omitted from this set.
116+
finalExpected := expectedOrgIDs
117+
if len(expectedOrgIDs) > 0 {
118+
expectedOrganizations, err := tx.GetOrganizations(ctx, database.GetOrganizationsParams{
119+
IDs: expectedOrgIDs,
120+
// Do not include deleted organizations
121+
Deleted: false,
122+
})
123+
if err != nil {
124+
return xerrors.Errorf("failed to get expected organizations: %w", err)
125+
}
126+
finalExpected = db2sdk.List(expectedOrganizations, func(org database.Organization) uuid.UUID {
127+
return org.ID
128+
})
121129
}
122130

123-
finalExpected := db2sdk.List(expectedOrganizations, func(org database.Organization) uuid.UUID {
124-
return org.ID
125-
})
126-
127131
// Find the difference in the expected and the existing orgs, and
128132
// correct the set of orgs the user is a member of.
129133
add, remove := slice.SymmetricDifference(existingOrgIDs, finalExpected)
@@ -142,7 +146,7 @@ func (s AGPLIDPSync) SyncOrganizations(ctx context.Context, tx database.Store, u
142146
})
143147
if err != nil {
144148
if xerrors.Is(err, sql.ErrNoRows) {
145-
// This should not happen because we check the org existance
149+
// This should not happen because we check the org existence
146150
// beforehand.
147151
notExists = append(notExists, orgID)
148152
continue

0 commit comments

Comments
 (0)