-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SMQ-2604 - Change PAT repo implementation #2680
base: main
Are you sure you want to change the base?
Conversation
@nyagamunene Please address comments @arvindh123 left. |
return dbScopes | ||
} | ||
|
||
func patToDBRecords(pat auth.PAT) (dbPat, []dbScope, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename to toDBPatScope
auth/postgres/pat.go
Outdated
return scope, nil | ||
} | ||
|
||
func fromAuthScope(patID string, scope auth.Scope) []dbScope { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename to toDBScope
, then pass the entire auth.PAT
.
auth/postgres/repo.go
Outdated
row, err := pr.db.NamedQueryContext(ctx, saveQuery, record) | ||
if err != nil { | ||
return postgres.HandleError(repoerr.ErrCreateEntity, err) | ||
} | ||
defer row.Close() | ||
|
||
scopeRow, err := pr.db.NamedQueryContext(ctx, saveScopeQuery, scope) | ||
if err != nil { | ||
return postgres.HandleError(repoerr.ErrCreateEntity, err) | ||
} | ||
defer scopeRow.Close() | ||
|
||
if err := pr.cache.Save(ctx, pat.ID, pat); err != nil { | ||
return errors.Wrap(repoerr.ErrCreateEntity, err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please User transaction(tx),
If anyone fails then all others should be reverted. With Tx you can achieve it easily, For refer implmenetation, please check roles, clients, channels repo.
auth/postgres/repo.go
Outdated
return auth.Scope{}, errors.Wrap(repoerr.ErrCreateEntity, err) | ||
} | ||
|
||
_, scope, err := patToDBRecords(pat) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use toDBScope
which will return only scope
Signature of the function will be func toDBScope(auth.PAT) (dbScope,error)
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2680 +/- ##
==========================================
- Coverage 42.28% 35.13% -7.16%
==========================================
Files 349 250 -99
Lines 47349 39094 -8255
==========================================
- Hits 20021 13735 -6286
+ Misses 25154 24281 -873
+ Partials 2174 1078 -1096 ☔ View full report in Codecov by Sentry. |
Signed-off-by: nyagamunene <[email protected]>
What type of PR is this?
What does this do?
Which issue(s) does this PR fix/relate to?
Have you included tests for your changes?
Did you document any new/modified feature?
Notes