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

Update tables to improve filtering, context cancellation in list calls. Closes #60 #61

Merged
merged 11 commits into from
Oct 27, 2021
Merged
22 changes: 22 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- main
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.29
args: --timeout=5m
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ builds:
- amd64
- arm64
ignore:
- goos: darwin # docs suggest that darwin arm64 should compile, but doesnt...
- goos: darwin # docs suggest that darwin arm64 should compile, but doesn't...
goarch: arm64

id: "steampipe-github"
Expand Down
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@

* **[Get started →](https://hub.steampipe.io/plugins/turbot/github)**
* Documentation: [Table definitions & examples](https://hub.steampipe.io/plugins/turbot/github/tables)
* Community: [Slack Channel](https://join.slack.com/t/steampipe/shared_invite/zt-oij778tv-lYyRTWOTMQYBVAbtPSWs3g)
* Community: [Slack Channel](https://steampipe.io/community/join)
* Get involved: [Issues](https://github.com/turbot/steampipe-plugin-github/issues)

## Quick start

Install the plugin with [Steampipe](https://steampipe.io):

```shell
steampipe plugin install github
```

Run a query:

```sql
select
name,
Expand All @@ -28,8 +30,9 @@ from
## Developing

Prerequisites:
- [Steampipe](https://steampipe.io/downloads)
- [Golang](https://golang.org/doc/install)

* [Steampipe](https://steampipe.io/downloads)
* [Golang](https://golang.org/doc/install)

Clone:

Expand All @@ -39,23 +42,27 @@ cd steampipe-plugin-github
```

Build, which automatically installs the new version to your `~/.steampipe/plugins` directory:
```

```sh
make
```

Configure the plugin:
```

```sh
cp config/* ~/.steampipe/config
vi ~/.steampipe/config/github.spc
```

Try it!
```

```shell
steampipe query
> .inspect github
```

Further reading:

* [Writing plugins](https://steampipe.io/docs/develop/writing-plugins)
* [Writing your first table](https://steampipe.io/docs/develop/writing-your-first-table)

Expand All @@ -64,5 +71,6 @@ Further reading:
Please see the [contribution guidelines](https://github.com/turbot/steampipe/blob/main/CONTRIBUTING.md) and our [code of conduct](https://github.com/turbot/steampipe/blob/main/CODE_OF_CONDUCT.md). All contributions are subject to the [Apache 2.0 open source license](https://github.com/turbot/steampipe-plugin-github/blob/main/LICENSE).

`help wanted` issues:
- [Steampipe](https://github.com/turbot/steampipe/labels/help%20wanted)
- [GitHub Plugin](https://github.com/turbot/steampipe-plugin-github/labels/help%20wanted)

* [Steampipe](https://github.com/turbot/steampipe/labels/help%20wanted)
* [GitHub Plugin](https://github.com/turbot/steampipe-plugin-github/labels/help%20wanted)
2 changes: 1 addition & 1 deletion config/github.spc
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ connection "github" {
# - `read:org`
# - `read:user`
# - `user:email`
#token = "YOUR_TOKEN_HERE"
# token = "YOUR_TOKEN_HERE"
}
6 changes: 4 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ select
from
github_my_repository;
```

```
+-------------------------------+------------+-------------+------------------+
| name | language | forks_count | stargazers_count |
Expand Down Expand Up @@ -74,9 +75,10 @@ connection "github" {
token = "ghp_111222333444555666777888999aaabbbcccddde"
}
```

- `token` - [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) for your GitHub account.

## Get involved

* Open source: https://github.com/turbot/steampipe-plugin-github
* Community: [Slack Channel](https://join.slack.com/t/steampipe/shared_invite/zt-oij778tv-lYyRTWOTMQYBVAbtPSWs3g)
- Open source: https://github.com/turbot/steampipe-plugin-github
- Community: [Slack Channel](https://steampipe.io/community/join)
2 changes: 1 addition & 1 deletion docs/tables/github_branch.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ select
from
github_branch
where
repository_full_name = 'turbot/steampipe'
repository_full_name = 'turbot/steampipe';
```

### Get commit details for each branch (Not working yet)
Expand Down
4 changes: 2 additions & 2 deletions docs/tables/github_branch_protection.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ select
from
github_branch_protection
where
repository_full_name = 'turbot/steampipe'
repository_full_name = 'turbot/steampipe';
```

### Get branch protection for a specific repo
Expand All @@ -26,5 +26,5 @@ from
github_branch_protection
where
repository_full_name = 'turbot/steampipe'
and name = 'main'
and name = 'main';
```
2 changes: 1 addition & 1 deletion docs/tables/github_community_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ select
from
github_community_profile
where
repository_full_name = 'turbot/steampipe'
repository_full_name = 'turbot/steampipe';
```
14 changes: 5 additions & 9 deletions docs/tables/github_issue.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Table: github_issue

GitHub Issues are used to track ideas, enhancements, tasks, or bugs for work on GitHub.
GitHub Issues are used to track ideas, enhancements, tasks, or bugs for work on GitHub.

The `github_issue` table can be used to query issues belonging to a repository, and **you must specify which repository** with `where repository_full_name='owner/repository'`. To list all the issues **assigned to you across all repositories** use the `github_my_issue` table instead.

Note that pull requests are technically also issues in GitHub, however we do not include them in the `github_issue` table; You should use the `github_pull_request` table to query PRs.
The `github_issue` table can be used to query issues belonging to a repository, and **you must specify which repository** with `where repository_full_name='owner/repository'`. To list all the issues **assigned to you across all repositories** use the `github_my_issue` table instead.

Note that pull requests are technically also issues in GitHub, however we do not include them in the `github_issue` table; You should use the `github_pull_request` table to query PRs.

## Examples

### List the issues in a repository

```sql
select
repository_full_name,
Expand All @@ -24,7 +24,6 @@ where
repository_full_name = 'turbot/steampipe';
```


### List the unassigned open issues in a repository

```sql
Expand Down Expand Up @@ -61,7 +60,6 @@ where
and tags ? 'bug';
```


### List the open issues in a repository assigned to a specific user

```sql
Expand All @@ -80,7 +78,6 @@ where
and state = 'open';
```


### Report of the number issues in a repository by author

```sql
Expand All @@ -97,8 +94,8 @@ order by
num_issues desc;
```


### Join with github_my_repository to find open issues in multiple repos that you own or contribute to

```sql
select
i.repository_full_name,
Expand All @@ -112,4 +109,3 @@ where
and i.state = 'open'
and i.repository_full_name = r.full_name;
```

4 changes: 1 addition & 3 deletions docs/tables/github_license.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Table: github_license

GitHub allows you to associate a license with your repository. The `github_license` table lists information about the available licenses.
GitHub allows you to associate a license with your repository. The `github_license` table lists information about the available licenses.

## Examples

Expand All @@ -15,7 +15,6 @@ from
github_license;
```


### View license permissions

```sql
Expand All @@ -26,7 +25,6 @@ from
github_license;
```


### Count your repositories by license

```sql
Expand Down
10 changes: 3 additions & 7 deletions docs/tables/github_my_issue.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Table: github_my_issue

GitHub Issues are used to track ideas, enhancements, tasks, or bugs for work on GitHub. The `github_my_issue` table lists issues that are assigned to you, across all repositories.
GitHub Issues are used to track ideas, enhancements, tasks, or bugs for work on GitHub. The `github_my_issue` table lists issues that are assigned to you, across all repositories.

To view **all the issues belonging to a repository**, use the `github_issue` table.


## Examples

### List all of the open issues assigned to you

```sql
select
repository_full_name,
Expand All @@ -22,7 +22,6 @@ where
state = 'open';
```


### List your open issues with a given label

```sql
Expand All @@ -39,15 +38,14 @@ where
and tags ? 'bug';
```


### List your 10 oldest open issues

```sql
select
repository_full_name,
issue_number,
created_at,
age (created_at),
age(created_at),
title,
state
from
Expand All @@ -58,5 +56,3 @@ order by
created_at
limit 10;
```


5 changes: 1 addition & 4 deletions docs/tables/github_my_organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ from
github_my_organization;
```


### Show members of an organization

```sql
Expand All @@ -38,7 +37,6 @@ where
login = 'turbot';
```


### Show Organization security settings

```sql
Expand All @@ -57,7 +55,6 @@ from
github_my_organization;
```


### Show collaborators in your organization's repositories that are not members of the organization

```sql
Expand All @@ -72,5 +69,5 @@ where
r.owner_login = o.login
and collaborator_login not in (
select m from github_my_organization, jsonb_array_elements_text(member_logins) as m
) ;
);
```
11 changes: 6 additions & 5 deletions docs/tables/github_my_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

You can own repositories individually, or you can share ownership of repositories with other people in an organization. The `github_my_repository` table will list tables you own, you collaborate on, or that belong to your organizations.
You can own repositories individually, or you can share ownership of repositories with other people in an organization. The `github_my_repository` table will list tables you own, you collaborate on, or that belong to your organizations.

To query **ANY** repository, including public repos, use the `github_repository` table.

Expand Down Expand Up @@ -50,6 +50,7 @@ from
where
not private;
```

OR

```sql
Expand All @@ -63,7 +64,7 @@ where
visibility = 'public';
```

### List all your repositories and their collaborators
### List all your repositories and their collaborators

```sql
select
Expand All @@ -90,10 +91,10 @@ order by
c ->> 'login';
```


### List collaborators who have "push" or "admin" to a specific repository

In this case, collaborators who have "push" or "admin" to the `turbot/steampipe-plugin-aws repository`:

```sql
select
name,
Expand All @@ -111,12 +112,12 @@ where
(c -> 'permissions' -> 'admin') :: bool
or (c -> 'permissions' -> 'push') :: bool
);
```

```

### List collaborators for organization repositories that are not organization members

In this case, for the `turbot` org:

```sql
select
name,
Expand Down
4 changes: 1 addition & 3 deletions docs/tables/github_my_team.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# 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 in your organizations.

## Examples

Expand All @@ -19,7 +18,6 @@ from
github_my_team;
```


### Permission for the teams

```sql
Expand Down
Loading