-
Notifications
You must be signed in to change notification settings - Fork 34
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
Factor out a high-level githubClient interface for all operations. #26
Conversation
Codecov Report
@@ Coverage Diff @@
## master #26 +/- ##
==========================================
- Coverage 54.86% 53.62% -1.25%
==========================================
Files 22 23 +1
Lines 1068 1130 +62
==========================================
+ Hits 586 606 +20
- Misses 447 484 +37
- Partials 35 40 +5
Continue to review full report at Codecov.
|
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 couple nits, otherwise LGTM 🥇
Thanks @luxas!
return nil, err | ||
} | ||
keys = append(keys, k) | ||
keys = append(keys, newDeployKey(c, apiObj)) |
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.
Add comment for consistency with other similar cases: // apiObj is already validated at ListKeys
@@ -17,6 +17,8 @@ limitations under the License. | |||
package github | |||
|
|||
import ( | |||
"fmt" | |||
|
|||
"github.com/google/go-github/v32/github" | |||
|
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.
Unnecessary newline
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.
Stefan wanted our internal imports to be separate from external, so I'll hold this for now
github/resource_organization.go
Outdated
// validateOrganizationAPI validates the apiObj received from the server, to make sure that it is | ||
// valid for our use. | ||
func validateOrganizationAPI(apiObj *github.Organization) error { | ||
if apiObj.Login == nil { |
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.
This could probably use validateAPIObject
like validateDeployKeyAPI
does, wdyt?
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 🚀
This allows us to
a) see, in a consistent way, how all API operations using
*github.Client
are done, to make sure that- pagination works
- all returned values are validated first
- HTTP errors are handled consistently
b) later, create mock implementations of the
githubClient
interface for unit testing of the clientc) focus on high-level operations in the main clients, not Github API details or pagination/validation/error handling.
cc @twelho @dinosk please review