-
Notifications
You must be signed in to change notification settings - Fork 14
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
Feature/keychain support #69
Conversation
@johananl I had a conflict on |
Just did that. |
Yeah, my bad. Had an older branch with the same name. |
You can run |
@johananl please review, too. thanks. |
@johananl I think that should make it into the next release too? What do you think? |
Move duplicate code to keychain package
I've rebased over current master. Please take a look here and comment or fix what you don't like. |
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.
✅ A review job has been created and sent to the PullRequest network.
Check the status or cancel PullRequest code review here - or - cancel by adding [!pr] to the title of the pull request.
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.
Welcome to PullRequest! Nice job abstracting this into an interface based on the windows/unix platforms. Overall this code looks pretty good, but I left a few different comments related to the error handling that could improve debugging and consistency. Feel free to reply inline if you have comments or suggestions.
I see multiple problems with this PR (the main one is that it doesn't build), however looks like this has been merged already so I don't have a lot left to do :-/ |
} | ||
|
||
func get(provider string) (pw []byte, err error) { | ||
pwString, err := keyring.Get(KeyChainName, provider) |
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.
The error isn't handled here. This makes the app attempt to authenticate even when now password was given or when Ctrl+C is pressed at the password prompt.
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.
Why does it need to be handled here? What you are describing is handled in keychain/keychain.go where it's actually exported.
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.
Lines 39 - 44 to be precise.
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.
In Go there are no exceptions. Every time you call a function which returns an error, you should check if the error is not nil. Even if you got a valid result back from the function, you could also get an error at the same time. This is perfectly valid in Go.
In this specific case, the app's flow continues after pressing Ctrl+C for example at the password prompt. This could lead to unexpected results and strange user experience.
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.
What you are describing is handled in keychain/keychain.go where it's actually exported.
This is not enough - if function C calls function B and function B calls function A and function A returns an error, you should have an error handling "chain":
func A() error {
return errors.New("Oh no!")
}
func B() error {
err := A()
if err != nil {
return err
}
}
func C() {
err := B()
if err != nil {
log.Fatalf("Something broke")
}
}
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.
The bottom line is - every time you have something like this:
err := whatever()
The following line should nearly always be:
if err != nil {
// Do something.
}
I'll elaborate more when I can walk through this thoroughly and actually test the new features, but what I've seen from a brief review:
I'll do my best to review this thoroughly ASAP. |
Yes, please open a new PR, I think that makes it easier to track. I've commented on your inline comment. |
I've taken the PR branch from @jspc in #51 and rebased on current master.
Then I've addressed the issues discussed in #51 and addressed them here and pushed them as a new PR since I lack permission to modify an exiting PR.