-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(github): Add Releases and Release Assets (#6097)
#### Summary <!-- Explain what problem this PR addresses --> <!--
- Loading branch information
Showing
15 changed files
with
468 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
plugins/source/github/docs/tables/github_release_assets.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Table: github_release_assets | ||
|
||
The composite primary key for this table is (**org**, **repository_id**, **id**). | ||
|
||
## Relations | ||
|
||
This table depends on [github_releases](github_releases.md). | ||
|
||
## Columns | ||
|
||
| Name | Type | | ||
| ------------- | ------------- | | ||
|_cq_source_name|String| | ||
|_cq_sync_time|Timestamp| | ||
|_cq_id|UUID| | ||
|_cq_parent_id|UUID| | ||
|org (PK)|String| | ||
|repository_id (PK)|Int| | ||
|id (PK)|Int| | ||
|url|String| | ||
|name|String| | ||
|label|String| | ||
|state|String| | ||
|content_type|String| | ||
|size|Int| | ||
|download_count|Int| | ||
|created_at|Timestamp| | ||
|updated_at|Timestamp| | ||
|browser_download_url|String| | ||
|uploader|JSON| | ||
|node_id|String| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Table: github_releases | ||
|
||
The composite primary key for this table is (**org**, **repository_id**, **id**). | ||
|
||
## Relations | ||
|
||
This table depends on [github_repositories](github_repositories.md). | ||
|
||
The following tables depend on github_releases: | ||
- [github_release_assets](github_release_assets.md) | ||
|
||
## Columns | ||
|
||
| Name | Type | | ||
| ------------- | ------------- | | ||
|_cq_source_name|String| | ||
|_cq_sync_time|Timestamp| | ||
|_cq_id|UUID| | ||
|_cq_parent_id|UUID| | ||
|org (PK)|String| | ||
|repository_id (PK)|Int| | ||
|tag_name|String| | ||
|target_commitish|String| | ||
|name|String| | ||
|body|String| | ||
|draft|Bool| | ||
|prerelease|Bool| | ||
|make_latest|String| | ||
|discussion_category_name|String| | ||
|generate_release_notes|Bool| | ||
|id (PK)|Int| | ||
|created_at|Timestamp| | ||
|published_at|Timestamp| | ||
|url|String| | ||
|html_url|String| | ||
|assets_url|String| | ||
|assets|JSON| | ||
|upload_url|String| | ||
|zipball_url|String| | ||
|tarball_url|String| | ||
|author|JSON| | ||
|node_id|String| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
plugins/source/github/resources/services/repositories/assets.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
plugins/source/github/resources/services/repositories/assets_fetch.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package repositories | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cloudquery/cloudquery/plugins/source/github/client" | ||
"github.com/cloudquery/plugin-sdk/schema" | ||
"github.com/google/go-github/v48/github" | ||
) | ||
|
||
func fetchAssets(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error { | ||
c := meta.(*client.Client) | ||
release := parent.Item.(*github.RepositoryRelease) | ||
repo := parent.Parent.Item.(*github.Repository) | ||
opts := &github.ListOptions{PerPage: 100} | ||
for { | ||
releases, resp, err := c.Github.Repositories.ListReleaseAssets(ctx, c.Org, *repo.Name, *release.ID, opts) | ||
if err != nil { | ||
return err | ||
} | ||
res <- releases | ||
opts.Page = resp.NextPage | ||
if opts.Page == resp.LastPage { | ||
break | ||
} | ||
} | ||
return nil | ||
} |
Oops, something went wrong.