-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat(database): add user management routes #365
Conversation
460fc1d
to
f725605
Compare
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.
I only have a question concerning the confirmation field, but otherwise lgtm
Name string `json:"name"` | ||
ReadOnly bool `json:"read_only"` | ||
Password string `json:"password,omitempty"` | ||
PasswordConfirmation string `json:"password_confirmation,omitempty"` |
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.
question: well, i know that the api doc specifies that we wait for a password confirmation, but in fact appsdeck-database does not receives this param. are you sure this field is really used?
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.
It is a required param from the DB-API
res := DatabaseUsersResponse{} | ||
err := c.DBAPI(app, addonID).SubresourceList(ctx, "databases", addonID, "users", nil, &res) | ||
if err != nil { | ||
return res.DatabaseUsers, errors.Wrap(ctx, err, "get database list of users") |
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.
Hi there,
I noticed that you now use errors.Wrap
instead of errgo.Notef
elsewhere in the code. Is it expected ? This require a little bit of work when using theses endpoints when there is an error (and create some headache).
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.
Hi François,
We depreciate the usage of the package errgo in general in favor of errors. This latter is not from standard library, because it doesn't implement wrapping system yet.
But you have probably noticed that it's not the latter package itself that is used here and more generally in our code base.
We are wrapping these two first packages to be retro compatible during the transition and to take context (ErrCtx
) by using our own package: "github.com/Scalingo/go-utils/errors/v2".
If by little bit of work you mean compare errors. I'd strongly advise you to use Is
and/or As
methods from ErrCtx, you can find them here:
https://github.com/Scalingo/go-utils/blob/77ec9e608897147630a4e56912c9318aa3d4c692/errors/cause.go#L10-L38
Their behavior is based on standard library.
FYI taking the context allows us to retrieve the root logger containing all fields, e.g. in middlewares.
Related to Scalingo/cli#1018