Skip to content

Commit

Permalink
Add tables github_team, github_team_member, github_team_repositor…
Browse files Browse the repository at this point in the history
…y` and bump `google/go-github` to v45.1.0 (#165)
  • Loading branch information
japborst authored Jun 16, 2022
1 parent cfd7228 commit 684095b
Show file tree
Hide file tree
Showing 50 changed files with 749 additions and 167 deletions.
14 changes: 8 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v0.16.0 [2022-06-05]

_What's new?_

- Added `github_team` table
- Added `github_team_member` table
- Added `github_team_repository` table

## v0.15.0 [2022-05-25]

_What's new?_
Expand Down Expand Up @@ -105,7 +113,6 @@ _Bug fixes_

- `github_repository` table will now return an empty row instead of `not found` error when the repository collaborator details are not available ([#89](https://github.com/turbot/steampipe-plugin-github/pull/89))


## v0.8.1 [2021-10-26]

_Bug fixes_
Expand Down Expand Up @@ -190,7 +197,6 @@ _What's new?_
- [github_traffic_view_daily](https://hub.steampipe.io/plugins/turbot/github/tables/github_traffic_view_daily) ([#32](https://github.com/turbot/steampipe-plugin-github/pull/32))
- [github_traffic_view_weekly](https://hub.steampipe.io/plugins/turbot/github/tables/github_traffic_view_weekly) ([#33](https://github.com/turbot/steampipe-plugin-github/pull/33))


## v0.3.0 [2021-04-30]

_What's new?_
Expand All @@ -210,7 +216,6 @@ _Bug fixes_
- Cleanup unnecessary logging in github_license ([#24](https://github.com/turbot/steampipe-plugin-github/pull/24))
- Github (lower h) references should be GitHub (capital H) throughout the docs etc ([#26](https://github.com/turbot/steampipe-plugin-github/pull/26))


## v0.2.0 [2021-03-18]

_What's new?_
Expand All @@ -231,7 +236,6 @@ _Bug fixes_
- Fixed: Renamed table `github_repository_issue` to `github_issue` ([#16](https://github.com/turbot/steampipe-plugin-github/pull/16))
- Fixed: Renamed table `github_team` to `github_my_team` ([#16](https://github.com/turbot/steampipe-plugin-github/pull/16))


## v0.1.1 [2021-02-25]

_Bug fixes_
Expand All @@ -240,14 +244,12 @@ _Bug fixes_
- Fix error for missing required quals [#40](https://github.com/turbot/steampipe-plugin-sdk/issues/42).
- Queries fail with error socket: too many open files [#190](https://github.com/turbot/steampipe/issues/190)


## v0.1.0 [2021-02-18]

_What's new?_

- Added support for [connection configuration](https://github.com/turbot/steampipe-plugin-github/blob/main/docs/index.md#connection-configuration). You may specify github `token` for each connection in a configuration file.


## v0.0.5 [2021-01-28]

_What's new?_
Expand Down
8 changes: 5 additions & 3 deletions docs/tables/github_my_team.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Table: github_my_team

Teams are groups of organization members that reflect your company or group's structure with cascading access permissions and mentions. The `github_my_team` table lists all teams in your organizations.
Teams are groups of organization members that reflect your company or group's structure with cascading access permissions and mentions. The `github_my_team` table lists all teams you're a member of across your organizations.

To view **all teams you have visibility to across your organizations,** use the `github_team` table.

## Examples

### Basic Team Info
### Basic info

```sql
select
Expand All @@ -18,7 +20,7 @@ from
github_my_team;
```

### Permission for the teams
### Get organization permission for each team

```sql
select
Expand Down
44 changes: 44 additions & 0 deletions docs/tables/github_team.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Table: github_team

Teams are groups of organization members that reflect your company or group's structure with cascading access permissions and mentions. The `github_team` table lists all teams you have visibility to across your organizations.

To list the teams that you're a member of across your organizations, use the `github_my_team` table.

## Examples

## List all visible teams

```sql
select
id,
name,
privacy,
description
from
github_team;
```

## List all visible teams in an organization

```sql
select
id,
name,
privacy,
description
from
github_team
where
organization = 'my_org';
```

## List the number of members for a single team

```sql
select
members_count
from
github_team
where
slug = 'team';
```
36 changes: 36 additions & 0 deletions docs/tables/github_team_member.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Table: github_team_member

The `github_team_member` table can be used to query information about members of a team. **You must specify the organization and team slug** in the where or join clause (`where organization= AND slug=`, `join github_team_member on organization= AND slug=`).

## Examples

### Get information about a specific organization's team members

```sql
select
login,
role
from
github_team_member
where
organization = 'my_org'
and slug = 'my-team';
```

### To get members for all teams and all organizations

```sql
select
t.organization,
t.name,
t.privacy,
t.description,
tm.login,
tm.role
from
github_team as t,
github_team_member as tm
where
t.organization = tm.organization
and t.slug = tm.slug
```
50 changes: 50 additions & 0 deletions docs/tables/github_team_repository.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Table: github_team_repository

A repository contains all of your project's files and each file's revision history.

The `github_team_repository` table can be used to query information about repositories that a team has access to. **You must specify the organization and team slug** in the where or join clause (`where organization= AND slug=`, `join github_team_repository on organization= AND slug=`).

To list all **your** repositories use the `github_my_repository` table instead. To get information about **any** repository, use the `github_repository` table instead.

## Examples

### Get information about a specific organization's team

```sql
select
name,
owner_login,
language,
forks_count,
stargazers_count,
subscribers_count,
watchers_count,
description
from
github_team_repository
where
organization = 'my_org'
and slug = 'my-team';
```

### To get repositories for all teams

```sql
select
t.id as team_id,
t.name as team_name,
t.privacy as team_privacy,
t.description as team_description,
tr.name as repo_name,
tr.fork as repo_is_fork,
tr.private as repo_is_private,
tr.archived as repo_is_archived,
tr.language as repo_primary_language
from
github_team as t,
github_team_repository AS tr
where
t.organization = 'my_org'
and t.organization = tr.organization
and t.slug = tr.slug
```
2 changes: 1 addition & 1 deletion github/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"strings"

"github.com/google/go-github/v33/github"
"github.com/google/go-github/v45/github"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin"
)

Expand Down
5 changes: 4 additions & 1 deletion github/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"github_actions_repository_runner": tableGitHubActionsRepositoryRunner(ctx),
"github_actions_repository_secret": tableGitHubActionsRepositorySecret(ctx),
"github_actions_repository_workflow_run": tableGitHubActionsRepositoryWorkflowRun(ctx),
"github_branch": tableGitHubBranch(ctx),
"github_branch_protection": tableGitHubBranchProtection(ctx),
"github_branch": tableGitHubBranch(ctx),
"github_commit": tableGitHubCommit(ctx),
"github_community_profile": tableGitHubCommunityProfile(ctx),
"github_gist": tableGitHubGist(),
Expand Down Expand Up @@ -50,6 +50,9 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"github_search_user": tableGitHubSearchUser(ctx),
"github_stargazer": tableGitHubStargazer(ctx),
"github_tag": tableGitHubTag(ctx),
"github_team_member": tableGitHubTeamMember(),
"github_team_repository": tableGitHubTeamRepository(),
"github_team": tableGitHubTeam(),
"github_traffic_view_daily": tableGitHubTrafficViewDaily(ctx),
"github_traffic_view_weekly": tableGitHubTrafficViewWeekly(ctx),
"github_user": tableGitHubUser(),
Expand Down
2 changes: 1 addition & 1 deletion github/table_github_actions_artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"context"

"github.com/google/go-github/v33/github"
"github.com/google/go-github/v45/github"

"github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin"
Expand Down
2 changes: 1 addition & 1 deletion github/table_github_actions_repository_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"context"

"github.com/google/go-github/v33/github"
"github.com/google/go-github/v45/github"

"github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin"
Expand Down
2 changes: 1 addition & 1 deletion github/table_github_actions_repository_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"context"

"github.com/google/go-github/v33/github"
"github.com/google/go-github/v45/github"

"github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin"
Expand Down
2 changes: 1 addition & 1 deletion github/table_github_actions_repository_workflow_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"context"

"github.com/google/go-github/v33/github"
"github.com/google/go-github/v45/github"

"github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin"
Expand Down
2 changes: 1 addition & 1 deletion github/table_github_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"context"

"github.com/google/go-github/v33/github"
"github.com/google/go-github/v45/github"

"github.com/turbot/go-kit/types"
"github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto"
Expand Down
2 changes: 1 addition & 1 deletion github/table_github_branch_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"strings"

"github.com/google/go-github/v33/github"
"github.com/google/go-github/v45/github"

"github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin"
Expand Down
8 changes: 6 additions & 2 deletions github/table_github_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"time"

"github.com/google/go-github/v33/github"
"github.com/google/go-github/v45/github"

"github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin"
Expand Down Expand Up @@ -174,13 +174,17 @@ func tableGitHubCommitGet(ctx context.Context, d *plugin.QueryData, h *plugin.Hy

client := connect(ctx, d)

opts := &github.ListOptions{
PerPage: 100,
}

type GetResponse struct {
commit *github.RepositoryCommit
resp *github.Response
}

getDetails := func(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
detail, resp, err := client.Repositories.GetCommit(ctx, owner, repo, sha)
detail, resp, err := client.Repositories.GetCommit(ctx, owner, repo, sha, opts)
return GetResponse{
commit: detail,
resp: resp,
Expand Down
2 changes: 1 addition & 1 deletion github/table_github_community_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"context"

"github.com/google/go-github/v33/github"
"github.com/google/go-github/v45/github"

"github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin"
Expand Down
32 changes: 16 additions & 16 deletions github/table_github_gist.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@ package github
import (
"context"

"github.com/google/go-github/v33/github"
"github.com/google/go-github/v45/github"

pb "github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin/transform"
)

func gitHubGistColumns() []*plugin.Column {
return []*plugin.Column{
// Top columns
{Name: "id", Type: pb.ColumnType_STRING, Description: "The unique id of the gist."},
{Name: "description", Type: pb.ColumnType_STRING, Description: "The gist description."},
{Name: "public", Type: pb.ColumnType_BOOL, Description: "If true, the gist is public, otherwise it is private."},
{Name: "html_url", Type: pb.ColumnType_STRING, Description: "The HTML URL of the gist."},
{Name: "comments", Type: pb.ColumnType_INT, Description: "The number of comments for the gist."},
{Name: "created_at", Type: pb.ColumnType_TIMESTAMP, Description: "The timestamp when the gist was created."},
{Name: "git_pull_url", Type: pb.ColumnType_STRING, Description: "The https url to pull or clone the gist."},
{Name: "git_push_url", Type: pb.ColumnType_STRING, Description: "The https url to push the gist."},
{Name: "node_id", Type: pb.ColumnType_STRING, Description: "The Node ID of the gist."},
{Name: "id", Type: proto.ColumnType_STRING, Description: "The unique id of the gist."},
{Name: "description", Type: proto.ColumnType_STRING, Description: "The gist description."},
{Name: "public", Type: proto.ColumnType_BOOL, Description: "If true, the gist is public, otherwise it is private."},
{Name: "html_url", Type: proto.ColumnType_STRING, Description: "The HTML URL of the gist."},
{Name: "comments", Type: proto.ColumnType_INT, Description: "The number of comments for the gist."},
{Name: "created_at", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp when the gist was created."},
{Name: "git_pull_url", Type: proto.ColumnType_STRING, Description: "The https url to pull or clone the gist."},
{Name: "git_push_url", Type: proto.ColumnType_STRING, Description: "The https url to push the gist."},
{Name: "node_id", Type: proto.ColumnType_STRING, Description: "The Node ID of the gist."},
// Only load relevant fields from the owner
{Name: "owner_id", Type: pb.ColumnType_INT, Description: "The user id (number) of the gist owner.", Transform: transform.FromField("Owner.ID")},
{Name: "owner_login", Type: pb.ColumnType_STRING, Description: "The user login name of the gist owner.", Transform: transform.FromField("Owner.Login")},
{Name: "owner_type", Type: pb.ColumnType_STRING, Description: "The type of the gist owner (User or Organization).", Transform: transform.FromField("Owner.Type")},
{Name: "updated_at", Type: pb.ColumnType_TIMESTAMP, Description: "The timestamp when the gist was last updated."},
{Name: "files", Type: pb.ColumnType_JSON, Transform: transform.FromField("Files").Transform(gistFileMapToArray), Description: "Files in the gist."},
{Name: "owner_id", Type: proto.ColumnType_INT, Description: "The user id (number) of the gist owner.", Transform: transform.FromField("Owner.ID")},
{Name: "owner_login", Type: proto.ColumnType_STRING, Description: "The user login name of the gist owner.", Transform: transform.FromField("Owner.Login")},
{Name: "owner_type", Type: proto.ColumnType_STRING, Description: "The type of the gist owner (User or Organization).", Transform: transform.FromField("Owner.Type")},
{Name: "updated_at", Type: proto.ColumnType_TIMESTAMP, Description: "The timestamp when the gist was last updated."},
{Name: "files", Type: proto.ColumnType_JSON, Transform: transform.FromField("Files").Transform(gistFileMapToArray), Description: "Files in the gist."},
}
}

Expand Down
2 changes: 1 addition & 1 deletion github/table_github_gitignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"context"

"github.com/google/go-github/v33/github"
"github.com/google/go-github/v45/github"

"github.com/turbot/steampipe-plugin-sdk/v3/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin"
Expand Down
Loading

0 comments on commit 684095b

Please sign in to comment.