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

Check access to GitHub repo on issuetracker initialization #70

Merged
merged 10 commits into from
Oct 23, 2020
Merged

Check access to GitHub repo on issuetracker initialization #70

merged 10 commits into from
Oct 23, 2020

Conversation

codykaup
Copy link
Contributor

@codykaup codykaup commented Oct 7, 2020

This PR closes #62 by making a quick request to the Github repo to ensure the user has access. If a 404 is returned, we log the output and exit early!

main.go Outdated Show resolved Hide resolved
Copy link
Owner

@preslavmihaylov preslavmihaylov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codykaup, thanks a lot for putting together this PR.

Unfortunately, it turns out to be more convoluted than what it seemed in hindsight. See my comment on the linked issue.

That's what is necessary to complete this while keeping the packages decoupled.

For example, in this PR you're making an http request in the config package, while the fetcher is the package which should wrap any kind of http calls.

If you still want to finish the PR after taking those changes into consideration, I am willing to assist in real-time if you'd want.

Otherwise, I'd suggest picking #63 which is a lot easier & doesn't require major refactoring.

@codykaup
Copy link
Contributor Author

@codykaup, thanks a lot for putting together this PR.

Unfortunately, it turns out to be more convoluted than what it seemed in hindsight. See my comment on the linked issue.

That's what is necessary to complete this while keeping the packages decoupled.

For example, in this PR you're making an http request in the config package, while the fetcher is the package which should wrap any kind of http calls.

If you still want to finish the PR after taking those changes into consideration, I am willing to assist in real-time if you'd want.

Otherwise, I'd suggest picking #63 which is a lot easier & doesn't require major refactoring.

Thanks for that comment, it gave me some good info to work from! I just pushed up the new layout to see what you think. Am I on the right track with what you were thinking?

Copy link
Owner

@preslavmihaylov preslavmihaylov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely in the right direction. There are some issues still left to address but merging this PR is definitely in hindsight.

I will be available to provide more active feedback these days to help getting it merged.

fetcher/fetcher.go Outdated Show resolved Hide resolved
)

// Validate checks if the user has access to the configured repo
func Validate(issueTracker config.IssueTracker, origin string) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you move the config.Validate code in here as well?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also, you can follow the same approach which was started there - returning an array of errors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried knocking this out and it results in quite a bit of refactoring to avoid the cyclic import between config and validation. I'm good with doing that but maybe it should be a separate PR to pull those apart? Unless I'm not thinking about it correctly which is also possible.

Copy link
Owner

@preslavmihaylov preslavmihaylov Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does moving config.Validate here result in a cyclic dependency? The validation component shouldn't be depended on by any other component, other than main.go?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done the extraction of the config.Validate function in this PR. Feel free to pull it after its merged

main.go Outdated Show resolved Hide resolved
testing/todocheck_test.go Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@codykaup
Copy link
Contributor Author

@preslavmihaylov sorry for the delay on this one, it's been a busy few days for me. I just pushed up some of the changes you recommended! I'm still thinking through the testing situation to remove the build flag (it feels ugly to me too). Since some testing configs include github.com/username/repo for the origin, the external call fails because it's not a valid repo (I also don't want the tests to make those externals requests every time). 🤔

@preslavmihaylov
Copy link
Owner

If the problem is that some testing configs include non-existent github repos, why don't you try changing them to a valid public github repo instead?

@codykaup
Copy link
Contributor Author

If the problem is that some testing configs include non-existent github repos, why don't you try changing them to a valid public github repo instead?

Turns out, it was a lot easier than I thought. There were just 2 places I needed to update so this one is ready!

testing/todocheck_test.go Show resolved Hide resolved
)

// Validate checks if the user has access to the configured repo
func Validate(issueTracker config.IssueTracker, origin string) error {
Copy link
Owner

@preslavmihaylov preslavmihaylov Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does moving config.Validate here result in a cyclic dependency? The validation component shouldn't be depended on by any other component, other than main.go?

)

// Validate checks if the user has access to the configured repo
func Validate(issueTracker config.IssueTracker, origin string) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done the extraction of the config.Validate function in this PR. Feel free to pull it after its merged

validation/validation.go Outdated Show resolved Hide resolved
@preslavmihaylov
Copy link
Owner

The PR I mentioned previously - #73 has been merged to master. Feel free to pull & update yours.

@codykaup
Copy link
Contributor Author

@preslavmihaylov just a heads up, this is ready for another review! Thanks for all your help on this one!

validation/validation.go Outdated Show resolved Hide resolved
@preslavmihaylov
Copy link
Owner

@codykaup this is the final touch & it's ready to go :)

@preslavmihaylov preslavmihaylov merged commit b064008 into preslavmihaylov:master Oct 23, 2020
@preslavmihaylov
Copy link
Owner

Thanks @codykaup a lot for this contribution! It's officially in master 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return an error if github repository is not found or private
2 participants