Skip to content

Commit 2e2d18a

Browse files
committed
backport of commit 5dfb5a0
1 parent 42bf2f0 commit 2e2d18a

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

internal/auth/oidc/repository_managed_group_members.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/hashicorp/boundary/internal/errors"
1212
"github.com/hashicorp/boundary/internal/kms"
1313
"github.com/hashicorp/boundary/internal/oplog"
14+
"github.com/hashicorp/boundary/internal/util"
1415
)
1516

1617
// SetManagedGroupMemberships will set the managed groups for the given account
@@ -207,7 +208,7 @@ func (r *Repository) ListManagedGroupMembershipsByMember(ctx context.Context, wi
207208
limit = opts.withLimit
208209
}
209210
reader := r.reader
210-
if opts.withReader != nil {
211+
if !util.IsNil(opts.withReader) {
211212
reader = opts.withReader
212213
}
213214
var mgs []*ManagedGroupMemberAccount
@@ -232,7 +233,7 @@ func (r *Repository) ListManagedGroupMembershipsByGroup(ctx context.Context, wit
232233
limit = opts.withLimit
233234
}
234235
reader := r.reader
235-
if opts.withReader != nil {
236+
if !util.IsNil(opts.withReader) {
236237
reader = opts.withReader
237238
}
238239
var mgs []*ManagedGroupMemberAccount

internal/iam/repository.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/hashicorp/boundary/internal/kms"
1414
"github.com/hashicorp/boundary/internal/oplog"
1515
"github.com/hashicorp/boundary/internal/types/scope"
16+
"github.com/hashicorp/boundary/internal/util"
1617
)
1718

1819
var ErrMetadataScopeNotFound = errors.New(context.Background(), errors.RecordNotFound, "iam", "scope not found for metadata", errors.WithoutEvent())
@@ -65,7 +66,7 @@ func (r *Repository) list(ctx context.Context, resources any, where string, args
6566
limit = opts.withLimit
6667
}
6768
reader := r.reader
68-
if opts.withReader != nil {
69+
if !util.IsNil(opts.withReader) {
6970
reader = opts.withReader
7071
}
7172
return reader.SearchWhere(ctx, resources, where, args, db.WithLimit(limit))
@@ -150,7 +151,7 @@ func (r *Repository) update(ctx context.Context, resource Resource, version uint
150151
reader := r.reader
151152
writer := r.writer
152153
needFreshReaderWriter := true
153-
if opts.withReader != nil && opts.withWriter != nil {
154+
if !util.IsNil(opts.withReader) && !util.IsNil(opts.withWriter) {
154155
reader = opts.withReader
155156
writer = opts.withWriter
156157
if !writer.IsTx(ctx) {

internal/iam/repository_grant_scope.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/hashicorp/boundary/internal/errors"
1212
"github.com/hashicorp/boundary/internal/kms"
1313
"github.com/hashicorp/boundary/internal/oplog"
14+
"github.com/hashicorp/boundary/internal/util"
1415
)
1516

1617
// AddRoleGrantScopes will add role grant scopes associated with the role ID in
@@ -235,7 +236,7 @@ func (r *Repository) SetRoleGrantScopes(ctx context.Context, roleId string, role
235236
writer := r.writer
236237
needFreshReaderWriter := true
237238
opts := getOpts(opt...)
238-
if opts.withReader != nil && opts.withWriter != nil {
239+
if !util.IsNil(opts.withReader) && !util.IsNil(opts.withWriter) {
239240
reader = opts.withReader
240241
writer = opts.withWriter
241242
needFreshReaderWriter = false

internal/iam/repository_role.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/hashicorp/boundary/internal/db"
1515
"github.com/hashicorp/boundary/internal/db/timestamp"
1616
"github.com/hashicorp/boundary/internal/errors"
17+
"github.com/hashicorp/boundary/internal/util"
1718
"github.com/hashicorp/go-dbw"
1819
)
1920

@@ -193,7 +194,7 @@ func (r *Repository) LookupRole(ctx context.Context, withPublicId string, opt ..
193194
}
194195

195196
var err error
196-
if opts.withReader != nil && opts.withWriter != nil {
197+
if !util.IsNil(opts.withReader) && !util.IsNil(opts.withWriter) {
197198
if !opts.withWriter.IsTx(ctx) {
198199
return nil, nil, nil, nil, errors.New(ctx, errors.Internal, op, "writer is not in transaction")
199200
}

0 commit comments

Comments
 (0)