-
Notifications
You must be signed in to change notification settings - Fork 70
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
76 google oauth config mutator #77
76 google oauth config mutator #77
Conversation
Signed-off-by: Chris Halbert <christopher.halbert@gmail.com>
Signed-off-by: Chris Halbert <christopher.halbert@gmail.com>
Signed-off-by: Chris Halbert <christopher.halbert@gmail.com>
Signed-off-by: Chris Halbert <christopher.halbert@gmail.com>
Signed-off-by: Chris Halbert <christopher.halbert@gmail.com>
be30822
to
520614c
Compare
google/google.go
Outdated
@@ -74,6 +77,19 @@ func Setup(redirectURL, credFile string, scopes []string, secret []byte) { | |||
} | |||
} | |||
|
|||
// Setup the authorization path without a config file |
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.
Go doc requires the first word to be the same as the func name.
👍 |
cbfedc0
to
0d3b4b8
Compare
👍 |
google/google.go
Outdated
@@ -100,29 +116,33 @@ func GetLoginURL(state string) string { | |||
return conf.AuthCodeURL(state) | |||
} | |||
|
|||
func WithLoginURL(url string) { | |||
loginURL = url |
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.
loginURL = url | |
loginURL = strings.TrimSpace(s) |
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.
Maybe better to use url.Parse(s), check error and if no error use u.String() to have a clean url string.
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.
With the error handling, would you suggest the signature change to func WithLoginURL(url string) (bool, 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.
I would say return error
is enough. Either there is an error or not :)
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'd suggest we are aiming for consistency on API. It is either
func SetupFromString(redirectURL, clientID string, clientSecret string, scopes []string, secret []byte) error
func WithLoginURL(url string) error
or
func SetupFromString(redirectURL, clientID string, clientSecret string, scopes []string, secret []byte)
func WithLoginURL(url string)
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 would suggest to go with the first, so return 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.
Makes sense - that seems more idiomatic too. I'll have that shortly..
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.
Sorry for the delay - had some distractions. I was just getting ready to update the PR and noticed that SetupFromString()
and Setup()
would differ with regards to their return value. The Setup()
function could more plausibly have errors, however, errors aren't being returned at this time. I do like the idea of returning an error WithLoginURL()
since there is possibility for a bad URL being added, but I feel like if I return an error from SetupFromString()
, I should also return an error for Setup()
. While that wouldn't break functionality, it could cause linting errors since return values aren't being accepted and handled. I'm going to make the changes for WithLoginURL()
as prescribed, but I'm interested to get your opinions on handling SetupFromString()
and Setup()
.
Signed-off-by: Chris Halbert <christopher.halbert@gmail.com>
fb4127e
to
f83e7e1
Compare
Signed-off-by: Chris Halbert <christopher.halbert@gmail.com>
Signed-off-by: Chris Halbert <christopher.halbert@gmail.com>
👍 |
1 similar comment
👍 |
google/google_test.go
Outdated
var testCases = []struct { | ||
description string | ||
urlParm string | ||
expectUrlLogin string |
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.
Linter says we should use upper case URL.
I know we don't follow it elsewhere but let's follow the convention for new things.
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.
Aye, will do!
👍 |
👍 |
1 similar comment
👍 |
This PR builds on the original work from #53 and addresses/closes #76