Git Product home page Git Product logo

turbot / steampipe-plugin-github Goto Github PK

View Code? Open in Web Editor NEW
67.0 12.0 26.0 1.15 MB

Use SQL to instantly query repositories, users, gists and more from GitHub. Open source CLI. No DB required.

Home Page: https://hub.steampipe.io/plugins/turbot/github

License: Apache License 2.0

Makefile 0.02% PLSQL 0.25% Go 99.73%
github github-cli github-client postgresql postgresql-fdw steampipe steampipe-plugin sql hacktoberfest backup

steampipe-plugin-github's Introduction

image

GitHub Plugin for Steampipe

Quick start

Install the plugin with Steampipe:

steampipe plugin install github

Configure the plugin using the configuration file:

vi ~/.steampipe/github.spc

Or environment variables:

export GITHUB_TOKEN=ghp_YOURTOKENHERE

Start Steampipe:

steampipe query

Run a query:

select
  name,
  language,
  forks_count,
  stargazers_count
from
  github_my_repository;

Engines

This plugin is available for the following engines:

Engine Description
Steampipe The Steampipe CLI exposes APIs and services as a high-performance relational database, giving you the ability to write SQL-based queries to explore dynamic data. Mods extend Steampipe's capabilities with dashboards, reports, and controls built with simple HCL. The Steampipe CLI is a turnkey solution that includes its own Postgres database, plugin management, and mod support.
Postgres FDW Steampipe Postgres FDWs are native Postgres Foreign Data Wrappers that translate APIs to foreign tables. Unlike Steampipe CLI, which ships with its own Postgres server instance, the Steampipe Postgres FDWs can be installed in any supported Postgres database version.
SQLite Extension Steampipe SQLite Extensions provide SQLite virtual tables that translate your queries into API calls, transparently fetching information from your API or service as you request it.
Export Steampipe Plugin Exporters provide a flexible mechanism for exporting information from cloud services and APIs. Each exporter is a stand-alone binary that allows you to extract data using Steampipe plugins without a database.
Turbot Pipes Turbot Pipes is the only intelligence, automation & security platform built specifically for DevOps. Pipes provide hosted Steampipe database instances, shared dashboards, snapshots, and more.

Developing

Prerequisites:

Clone:

git clone https://github.com/turbot/steampipe-plugin-github.git
cd steampipe-plugin-github

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

make

Configure the plugin:

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

Try it!

steampipe query
> .inspect github

Further reading:

Open Source & Contributing

This repository is published under the Apache 2.0 (source code) and CC BY-NC-ND (docs) licenses. Please see our code of conduct. We look forward to collaborating with you!

Steampipe is a product produced from this open source software, exclusively by Turbot HQ, Inc. It is distributed under our commercial terms. Others are allowed to make their own distribution of the software, but cannot use any of the Turbot trademarks, cloud services, etc. You can learn more in our Open Source FAQ.

Get Involved

Join #steampipe on Slack →

Want to help but don't know where to start? Pick up one of the help wanted issues:

steampipe-plugin-github's People

Contributors

aminvielledebatatbedrock avatar bigdatasourav avatar breck7 avatar c0d3r-arnab avatar cbruno10 avatar dboeke avatar dependabot[bot] avatar e-gineer avatar francois2metz avatar graza-io avatar japborst avatar johnsmyth avatar jramosf avatar judell avatar karanpopat avatar khushboo9024 avatar lalitlab avatar madhushreeray30 avatar mheiges avatar misraved avatar mridang avatar parthai avatar paulami30 avatar popsu avatar qmacro avatar rmhartog avatar rupeshpatil20 avatar subhajit97 avatar thejokersthief avatar vincenthardouin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

steampipe-plugin-github's Issues

Fix table github_repository collaborators not found

Describe the bug
A clear and concise description of what the bug is.

Steampipe version (steampipe -v)
Example: v0.3.0

Plugin version (steampipe plugin list)
Example: v0.5.0

To reproduce
Steps to reproduce the behavior (please include relevant code and/or commands).

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

joins dont work as expected on key columns

Joining these tables on key columns always returns no records:

  • github_repository_issue
  • github_user

Joining these tables on key columns doesnt as expected:

  • github_gist
  • github_organization

This works:

select
  repository_full_name,
  issue_number,
  title
from
  github_repository_issue
where 
  not is_pull_request 
  and  repository_full_name = 'turbot/steampipe-plugin-github'

This should work, but does not:

select
  i.repository_full_name,
  i.issue_number,
  i.title
from
  github_repository as r,
  github_repository_issue as i
where 
  not i.is_pull_request 
  and  i.repository_full_name = r.full_name

This is due to SDK bug turbot/steampipe-postgres-fdw#3

Add outside_collaborators columns to the github_repository table

Is your feature request related to a problem? Please describe.

The collaborators columns on github_repository currently include all collaborators - both team members (internal) and outside collaborators. This is helpful, but there is no way to tell them apart and check for outside collaborators only.

Describe the solution you'd like

Add a new outside_collaborators column, which is just the outside collaborators for the repo.

Describe alternatives you've considered

Tried to filter the collaborators, but the API does not return any way to tell them apart.

When selecting from github.github_branch, passing a repository_full_name with no slash in results in index out of range panic

Describe the bug
When selecting from github_branch, passing a repository_full_name with no slash in results in index out of range panic

 select * from github.github_branch where repository_full_name = 'steampipe'
Error: rpc error: code = Internal desc = list call tableGitHubBranchList failed with panic runtime error: index out of range [1] with length 1

Steampipe version (steampipe -v)
v0.8.0

Plugin version (steampipe plugin list)
v0.6.0

To reproduce

select * from github.github_branch where repository_full_name = 'steampipe'

Expected behavior
An empty result set

Additional context
This does not give the crash

select * from github.github_branch where repository_full_name = 'steampipe/'

github_user RPC error

Currenting throwing an error on github_user table as follows:

> select * from github_user
Error: pq: rpc error: code = Internal desc = 'List' call requires an '=' qual for column: login

Same when using a SQL client with the service. Confirmed the Access Token has the required scopes.

Also small docs note: https://hub.steampipe.io/plugins/turbot/github

scope for read:email should be user:email I think?

Remove duplicate column "members_can_create_repositories" in github_organization and github_my_organization tables

Describe the bug
This information is already captured in the members_can_create_repos column and all of the data for members_can_create_repositories comes through as null today anyway.

Steampipe version (steampipe -v)
v0.5.0

Plugin version (steampipe plugin list)
v0.4.0

To reproduce
select * from github_my_organization;

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

report gist filenames in table_github_gist

It's hard to make sense of the table_github_gist listing without filenames. I found here the element Files.

I tried adding this to the table_github_gist.go:

{Name: "files", Type: pb.ColumnType_JSON, Description: "The filename."},

Now I can do this:

> select
  files->jsonb_object_keys(files)->'filename' as name,
  files->jsonb_object_keys(files)->'language' as language,
  description
from github_my_gist limit 5
+------------------------------+--------------+----------------------------------------------------+
| name                         | language     | description                                        |
+------------------------------+--------------+----------------------------------------------------+
| "ucdavis-april-2019.md"      | "Markdown"   |                                                    |
| "plpython.md"                | "Markdown"   |                                                    |
| "internal_and_public_id"     | <null>       | convert between hypothesis internal and public ids |
| "addMembers.js"              | "JavaScript" |                                                    |
| "async-postgres-listener.py" | "Python"     |                                                    |
+------------------------------+--------------+----------------------------------------------------+

The downside is that this requires some Postgres mojo that makes me stop and think, despite my having used Postgres JSONB a lot. So while this works for me I'm not sure I'd recommend for others. Presumably the plugin could use a derived type that hoists these fields to the top level? Anyway, it was an easy and instructive workaround.

panic when login for github_organization doesn't exist

The login I should've used was boto but I guessed amazon and got this result:

select * from github_organization where login = 'amazon';

ERROR: rpc error: code = Internal desc = hydrate function getOrganizationDetail failed with panic runtime error: invalid memory address or nil pointer dereference

Escape sequence "\'" is invalid in github_commit query

I tried the first example at https://hub.steampipe.io/plugins/turbot/github/tables/github_issue.

select
  sha,
  author_login,
  author_date,
  message
from
  github_commit
where
  repository_full_name = 'turbot/steampipe'
order by
  author_date desc;

Result in 0.8.2:

ERROR: invalid input syntax for type json
DETAIL: Escape sequence "'" is invalid.
CONTEXT: JSON data, line 1: ...pe-postgre-fdw to v0.2.2 - fix JSON data with ''...

Does this repro for others?

This works.

select
  *
from
  github_commit
where
  repository_full_name = 'turbot/steampipe' 
limit 1;

api.github.com/repos/microsoft/vscode/commits costs 1 API call per commit

I was using this code to load 88,545 commits into a table that I still have in Steampipe.

create table commits as (
  select
    *
  from
    github_commit g
  where
    g.repository_full_name = 'microsoft/vscode'
);

So this was clearly possible within the 5K/hr API rate limit, and I did it multiple times over several days.

In the course of that, I triggered a reset a couple of times.

Now, the above code only gets ~2200 commits, and costs me about that many calls to get them, per https://api.github.com/rate_limit. I'll never get 88K commits again at that rate!

    "rate": {
        "limit": 5000,
        "used": 2270,
        "remaining": 2730,
        "reset": 1634539423
    }

What could have changed? I don't see how it's Steampipe but maybe it's us? Could GitHub be punishing me for infractions? Could they have imposed some other kind of general limit between Friday and Sunday? Should someone with a different GitHub personal access token try to repro this? And finally, @nathan, should this be a separate bug report vs an addendum to this feature request?

I just checked this again. Got only two steps into a dozen-stage pipeline that was running successfully, and repeatedly, until last night.

create table if not exists vscode_log(time timestamp, event text);

insert into vscode_log(time, event) values (now(), 'vscode_org_members');
-- ~50 api calls
create table vscode_org_members as (
  select
    g.name,
    g.login,
    jsonb_array_elements_text(g.member_logins) as member_login
  from
    github_organization g
  where
    g.login = 'microsoft'
);

insert into vscode_log(time, event) values (now(), 'vscode_commits');
-- ~1000 API calls for 1000 records: 1 call per commit?!?
create table vscode_commits as (
  select
    *
  from
    github_commit g
  where
    g.repository_full_name = 'microsoft/vscode'
  limit 1000
);

Postman:

"rate": {
        "limit": 5000,
        "used": 1108,
        "remaining": 3892,
        "reset": 1634578299
    }

I'm stuck. I built and tested a pipeline, have all the data from it sitting in local tables, wrote an article about all that, intending to publish the pipeline and encourage folks to try it for themselves, but now I cannot myself run the pipeline.

Update: I can get 100 commits per API call going straight to
https://api.github.com/repos/microsoft/vscode/commits?per_page=100.

Tried rolling back to plugin .6 with older sdk, still the same.

Update tables to improve filtering, context cancellation in list calls

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Invalid input syntax for type json error while running queries on github_commit table

Describe the bug
On running the query

select * from github_commit where repository_full_name='turbot/steampipe'

Output:

Error: invalid input syntax for type json

Steampipe version (steampipe -v)
Example: v0.8.1

Plugin version (steampipe plugin list)
Example: v0.6.0

To reproduce
Steps to reproduce the behaviour (please include relevant code and/or commands).

Expected behaviour
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

Support for GitHub Enterprise

It would be great if the GitHub plugin supported GitHub Enterprise. This would be mostly a change to the config and connection setup to allow a custom host etc.

After development, we'll require someone with access to GitHub Enterprise to help with final testing.

Update all tables that use custom retry logic to use RetryHydrate function from SDK

Is your feature request related to a problem? Please describe.
When retrying API calls due to errors, today we use custom retry logic that sometimes fails or runs inefficiently.

Describe the solution you'd like
We should switch to using the RetryHydrate function from the plugin SDK for better error handling/retry logic, e.g., f7142a2.

Describe alternatives you've considered
N/A

Additional context
N/A

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.