Skip to content
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

Merged
14 commits merged into from Dec 7, 2018
Merged

Feature/keychain support #69

14 commits merged into from Dec 7, 2018

Conversation

ghost
Copy link

@ghost ghost commented Sep 12, 2018

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.

@ghost
Copy link
Author

ghost commented Sep 12, 2018

@johananl I had a conflict on Gopkg.lock which I'm not sure if I resolved that right.

@ghost ghost changed the title [WIP] Feature/keychain support Feature/keychain support Sep 12, 2018
@ghost
Copy link
Author

ghost commented Sep 12, 2018

Can you please rebase over latest master?

Just did that.

@johananl
Copy link
Collaborator

Yeah, my bad. Had an older branch with the same name.

@johananl
Copy link
Collaborator

johananl commented Sep 12, 2018

@johananl I had a conflict on Gopkg.lock which I'm not sure if I resolved that right.

You can run dep ensure to verify. It will change things in Gopkg.lock if necessary.

@ghost
Copy link
Author

ghost commented Sep 25, 2018

@johananl please review, too. thanks.

@ghost
Copy link
Author

ghost commented Nov 7, 2018

@johananl I think that should make it into the next release too? What do you think?

@ghost ghost added this to the 0.7.0 milestone Dec 3, 2018
@ghost ghost requested a review from johananl December 4, 2018 07:54
@ghost
Copy link
Author

ghost commented Dec 4, 2018

I've rebased over current master. Please take a look here and comment or fix what you don't like.

@ghost ghost mentioned this pull request Dec 4, 2018
@ghost ghost added the enhancement label Dec 4, 2018
Copy link

@pullrequest pullrequest bot left a 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.

Copy link

@pullrequest pullrequest bot left a 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.


Was this helpful? Yes | No

keychain/keychain.go Outdated Show resolved Hide resolved
cmd/providers.go Outdated Show resolved Hide resolved
keychain/keychain_windows.go Outdated Show resolved Hide resolved
keychain/keychain.go Show resolved Hide resolved
@ghost ghost merged commit 3bd7bcf into allcloud-io:master Dec 7, 2018
@ghost ghost deleted the feature/keychain_support branch December 7, 2018 16:48
@ghost ghost mentioned this pull request Dec 7, 2018
@johananl
Copy link
Collaborator

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 :-/

@ghost
Copy link
Author

ghost commented Dec 10, 2018

@johananl ok, screwed that one up. Fixed in #77.

So what other issues do you see? care to elaborate?

}

func get(provider string) (pw []byte, err error) {
pwString, err := keyring.Get(KeyChainName, provider)
Copy link
Collaborator

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.

Copy link
Author

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.

Copy link
Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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")
	}
}

Copy link
Collaborator

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.
}

@johananl
Copy link
Collaborator

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:

  • There is an unhandled error. I commented inline.
  • There is inconsistent capitalization in multiple places.
  • Some user messages and documentation changes could be phrased better.

I'll do my best to review this thoroughly ASAP.
Shall I open a new PR with suggested changes for your review instead?

@ghost
Copy link
Author

ghost commented Dec 10, 2018

Yes, please open a new PR, I think that makes it easier to track.

I've commented on your inline comment.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants