Skip to content

Commit

Permalink
Add table github_package and github_package_version
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthaI committed Oct 24, 2024
1 parent 1a0b9dd commit 05d37c0
Show file tree
Hide file tree
Showing 5 changed files with 644 additions and 0 deletions.
181 changes: 181 additions & 0 deletions docs/tables/github_package.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
---
title: "Steampipe Table: github_package - Query GitHub Packages using SQL"
description: "Allows users to query GitHub Packages, including package metadata, versions, owner details, and associated repositories, providing insights into the package management within GitHub repositories."
---

# Table: github_package - Query GitHub Packages using SQL

GitHub Packages allow you to store and manage container images and other packages directly within your GitHub repositories. With this table, you can query details about GitHub packages within an organization, including information about the package itself, its owner, associated repositories, and visibility.

## Table Usage Guide

The `github_package` table provides detailed insights into packages hosted in GitHub's container registry or other package managers like npm. You can retrieve information about the package owner, repository, creation time, versioning details, and more. This is particularly useful for monitoring and managing package versions and repository associations in an organization.

**Important Notes**
- You must specify the `organization` column in the `where` clause to query the table.
- OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. If the package_type belongs to a GitHub Packages registry that only supports repository-scoped permissions, the `repo` scope is also required. Please refer [Permissions for repository-scoped packages](https://docs.github.com/en/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages) for more information.

## Examples

### List all packages for a specific organization
Retrieve the details of all packages available in a specified GitHub organization, including information about the owner, repository, and package type.

```sql+postgres
select
id,
name,
package_type,
repository_full_name,
visibility,
created_at,
updated_at,
owner_login,
url
from
github_package
where
organization = 'turbot';
```

```sql+sqlite
select
id,
name,
package_type,
repository_full_name,
visibility,
created_at,
updated_at,
owner_login,
url
from
github_package
where
organization = 'turbot';
```

### List all public packages for an organization
Filter and list only the packages that are publicly visible in a specific GitHub organization. This is helpful for managing public packages in your organization.

```sql+postgres
select
id,
name,
package_type,
repository_full_name,
visibility,
html_url,
owner_login
from
github_package
where
organization = 'turbot'
and visibility = 'public';
```

```sql+sqlite
select
id,
name,
package_type,
repository_full_name,
visibility,
html_url,
owner_login
from
github_package
where
organization = 'turbot'
and visibility = 'public';
```

### Find packages associated with private repositories
Identify packages that are tied to private repositories within a GitHub organization, allowing you to manage internal packages.

```sql+postgres
select
name,
repository_full_name,
repository_private,
owner_login
from
github_package
where
organization = 'turbot'
and repository_private = true;
```

```sql+sqlite
select
name,
repository_full_name,
repository_private,
owner_login
from
github_package
where
organization = 'turbot'
and repository_private = 1;
```

### Get the details of a specific package by name
Retrieve comprehensive details about a specific package by filtering based on the package name. It is useful for analyzing a single package's metadata, owner, and repository association.

```sql+postgres
select
id,
name,
package_type,
repository_full_name,
owner_login,
created_at,
updated_at,
url
from
github_package
where
organization = 'turbot'
and name = 'steampipe/plugin/turbot/aws';
```

```sql+sqlite
select
id,
name,
package_type,
repository_full_name,
owner_login,
created_at,
updated_at,
url
from
github_package
where
organization = 'turbot'
and name = 'steampipe/plugin/turbot/aws';
```

### List all versions of a package for an organization
Explore the versioning details for a specific package, showing the available versions and metadata for each version.

```sql+postgres
select
name,
jsonb_array_elements_text(package_version->'versions') as version
from
github_package
where
organization = 'turbot'
and name = 'steampipe/plugin/turbot/aws';
```

```sql+sqlite
select
name,
json_extract(package_version, '$.versions[0]') as version
from
github_package
where
organization = 'turbot'
and name = 'steampipe/plugin/turbot/aws';
```
175 changes: 175 additions & 0 deletions docs/tables/github_package_version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
---
title: "Steampipe Table: github_package_version - Query GitHub Package Versions using SQL"
description: "Allows users to query GitHub Package Versions, providing insights into the metadata, release information, visibility, and creation details of each version."
---

# Table: github_package_version - Query GitHub Package Versions using SQL

GitHub Package Versions represent different versions of packages stored in GitHub, such as container images, npm packages, and more. These versions hold critical details about the state of a package at a specific point in time, including release information, tags, metadata, and visibility.

## Table Usage Guide

The `github_package_version` table allows you to query detailed information about different versions of packages in GitHub's package registry. This includes data such as the package author, digest, release information, and the visibility of the version (whether public or private).

**Important Notes**
- You must specify the `organization` column in the `where` clause to query the table.
- OAuth app tokens and personal access tokens (classic) need the `read:packages` scope to use this endpoint. If the package_type belongs to a GitHub Packages registry that only supports repository-scoped permissions, the `repo` scope is also required. Please refer [Permissions for repository-scoped packages](https://docs.github.com/en/packages/learn-github-packages/about-permissions-for-github-packages#permissions-for-repository-scoped-packages) for more information.

## Examples

### List all versions of a specific package
This query retrieves all the versions for a specific package in an organization. It includes details such as the version's digest, creation date, and visibility status.

```sql+postgres
select
id,
package_name,
digest,
prerelease,
created_at,
visibility
from
github_package_version
where
organization = 'turbot'
and package_name = 'steampipe/plugin/turbot/aws';
```

```sql+sqlite
select
id,
package_name,
digest,
prerelease,
created_at,
visibility
from
github_package_version
where
organization = 'turbot'
and package_name = 'steampipe/plugin/turbot/aws';
```

### List all public package versions for an organization
This query lists all publicly visible versions of packages in a GitHub organization, including their package type and associated metadata.

```sql+postgres
select
package_name,
package_type,
digest,
visibility,
created_at,
updated_at
from
github_package_version
where
organization = 'turbot'
and visibility = 'public';
```

```sql+sqlite
select
package_name,
package_type,
digest,
visibility,
created_at,
updated_at
from
github_package_version
where
organization = 'turbot'
and visibility = 'public';
```

### List pre-release package versions for a specific package
This query retrieves all the pre-release versions of a specific package in an organization. Pre-release versions are used for testing before a package is officially released.

```sql+postgres
select
id,
package_name,
prerelease,
created_at,
html_url
from
github_package_version
where
organization = 'turbot'
and package_name = 'steampipe/plugin/turbot/aws'
and prerelease = true;
```

```sql+sqlite
select
id,
package_name,
prerelease,
created_at,
html_url
from
github_package_version
where
organization = 'turbot'
and package_name = 'steampipe/plugin/turbot/aws'
and prerelease = 1;
```

### Get metadata of a specific package version
This query retrieves metadata details for a specific package version. Metadata can include additional version-specific information, such as description, version number, and other properties.

```sql+postgres
select
id,
package_name,
jsonb_pretty(metadata) as metadata
from
github_package_version
where
organization = 'turbot'
and package_name = 'steampipe/plugin/turbot/aws'
and id = 12345;
```

```sql+sqlite
select
id,
package_name,
json_extract(metadata, '$') as metadata
from
github_package_version
where
organization = 'turbot'
and package_name = 'steampipe/plugin/turbot/aws'
and id = 12345;
```

### List the tags associated with a package version
This query retrieves the tags associated with a specific package version. Tags help identify different aspects of a version and can assist with version management.

```sql+postgres
select
id,
package_name,
jsonb_array_elements_text(tags) as tag
from
github_package_version
where
organization = 'turbot'
and package_name = 'steampipe/plugin/turbot/aws'
and id = 12345;
```

```sql+sqlite
select
id,
package_name,
json_extract(tags, '$[0]') as tag
from
github_package_version
where
organization = 'turbot'
and package_name = 'steampipe/plugin/turbot/aws'
and id = 12345;
```
2 changes: 2 additions & 0 deletions github/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"github_organization_external_identity": tableGitHubOrganizationExternalIdentity(),
"github_organization_member": tableGitHubOrganizationMember(),
"github_organization_collaborator": tableGitHubOrganizationCollaborator(),
"github_package": tableGitHubPackage(),
"github_package_version": tableGitHubPackageVersion(),
"github_pull_request": tableGitHubPullRequest(),
"github_pull_request_comment": tableGitHubPullRequestComment(),
"github_pull_request_review": tableGitHubPullRequestReview(),
Expand Down
Loading

0 comments on commit 05d37c0

Please sign in to comment.