Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

Commit

Permalink
fix: Issue fetching (#20)
Browse files Browse the repository at this point in the history
* fix: Issue fetching

* fix test
  • Loading branch information
roneli committed Aug 7, 2022
1 parent 36b0433 commit 1753dd6
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
1 change: 0 additions & 1 deletion docs/README.md

This file was deleted.

44 changes: 44 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Github Provider

The CloudQuery Github provider extracts and transforms your AWS cloud assets configuration into PostgreSQL.

## Install

```shell
cloudquery init github
```

## Authentication

CloudQuery requires only a Personal Access Token, follow this [guide](https://docs.github.com/en/enterprise-server@3.4/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) by github
on how to create a personal access token for CloudQuery.

## Configuration

CloudQuery needs to be authenticated with your Github account's Personal Token in order to fetch information about your Github organizations.
CloudQuery requires only *read* permissions (we will never make any changes to your github account or organizations),
so, following the principle of least privilege, it's recommended to grant it read-only permissions.

Add the following Block your your providers list in your `cloudquery.yml` configuration.
```yaml
- name: github
configuration:
access_token: "<YOUR ACCESS TOKEN HERE>
orgs: ["<YOUR ORG NAME>"]
resources:
- organizations
- repositories
- teams
- billing.actions
- billing.packages
- billing.storage
- issues
- hooks
- installations
- external_groups



```

More information can be found in the [CloudQuery documentation](https://docs.cloudquery.io/docs/developers/debugging)
2 changes: 2 additions & 0 deletions resources/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,8 @@ func Issues() *schema.Table {
func fetchIssues(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
c := meta.(*client.Client)
opts := &github.IssueListOptions{
Filter: "all",
State: "all",
ListOptions: github.ListOptions{
Page: 0,
PerPage: 100,
Expand Down
6 changes: 4 additions & 2 deletions resources/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,10 @@ func resolveOrganizationMembersTextMatches(ctx context.Context, meta schema.Clie
func fetchOrganizationMemberMemberships(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
c := meta.(*client.Client)
m := parent.Item.(*github.User)

membership, _, err := c.Github.Organizations.GetOrgMembership(ctx, *m.Name, c.Org)
if m == nil {
return nil
}
membership, _, err := c.Github.Organizations.GetOrgMembership(ctx, *m.Login, c.Org)
if err != nil {
return diag.WrapError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion resources/organizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func buildOrganizations(t *testing.T, ctrl *gomock.Controller) client.GithubServ
if err := faker.FakeDataSkipFields(&m, []string{}); err != nil {
t.Fatal(err)
}
mock.EXPECT().GetOrgMembership(gomock.Any(), *u.Name, gomock.Any()).Return(
mock.EXPECT().GetOrgMembership(gomock.Any(), *u.Login, gomock.Any()).Return(
&m, &github.Response{}, nil)

return client.GithubServices{Organizations: mock}
Expand Down

0 comments on commit 1753dd6

Please sign in to comment.