-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
connector/gitlab: Fix regexp in Link parser #1090
Conversation
Can you add a test? |
Added test |
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.
Build failing because of golint.
Mind addressing that then squashing your commits?
connector/gitlab/gitlab_test.go
Outdated
) | ||
|
||
func TestNextURL(t *testing.T) { | ||
linkHeader := "<https://gitlab.com/api/v4/groups?page=3&per_page=20>; rel=\"next\", " + |
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.
nit: we generally prefer table driven tests https://github.com/golang/go/wiki/TableDrivenTests
If you want to add that here that works, if not I'm fine with the test as is.
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'll fix! Thanks!
connector/gitlab/gitlab.go
Outdated
} else { | ||
break | ||
func nextURL(url string, link string) string { | ||
reNext := regexp.MustCompile("<([^>]+)>; rel=\"next\"") |
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.
nit: move these to global vars so we don't re-compile them every time the function is called
var (
reNext = regexp.MustCompile("...")
reLast = regexp.MustCompile("...")
)
func nextURL() {
// .. use reNext and reLast
}
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.
Will do!
connector/gitlab/gitlab.go
Outdated
|
||
if len(reNext.FindStringSubmatch(link)) > 1 { | ||
return reNext.FindStringSubmatch(link)[1] | ||
} else { |
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 lint picked this up as fishy
/home/travis/gopath/src/github.com/coreos/dex/connector/gitlab/gitlab.go:296:9: if block ends with a return statement, so drop this else and outdent its block
Found 1 lint suggestions; failing.
a85ea97
to
2d4a932
Compare
squashed and fixed the above comments |
2d4a932
to
4605fdd
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.
lgtm
Awesome! Thanks! Looking forward to a patch release soon then. |
@ericchiang when can we expect this merged? |
@lsjostro sorry was out of the office. |
connector/gitlab: Fix regexp in Link parser
Fix regression in Link parser.
.* is to ambiguous.