Skip to content

Commit db66fdc

Browse files
committed
fix: add repository_id to github_repository_* tables
1 parent e2b04ca commit db66fdc

19 files changed

+123
-18
lines changed

cloudql/github/table_github_repository.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ import (
99

1010
func sharedRepositoryColumns() []*plugin.Column {
1111
return []*plugin.Column{
12+
{
13+
Name: "repository_id",
14+
Type: proto.ColumnType_INT,
15+
Transform: transform.FromField("Description.GitHubRepoID"),
16+
Description: "Unique identifier of the GitHub repository.",
17+
},
1218
{
1319
Name: "repository_full_name",
1420
Type: proto.ColumnType_STRING,

cloudql/github/table_github_repository_collaborator.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ import (
1212

1313
func gitHubRepositoryCollaboratorColumns() []*plugin.Column {
1414
return []*plugin.Column{
15+
{
16+
Name: "repository_id",
17+
Type: proto.ColumnType_INT,
18+
Transform: transform.FromField("Description.RepositoryID"),
19+
Description: "Unique identifier of the GitHub repository.",
20+
},
1521
{Name: "repository_name", Type: proto.ColumnType_STRING, Description: "The full name of the repository, including the owner and repo name.",
1622
Transform: transform.FromField("Description.RepositoryName")},
1723
{Name: "repository_full_name", Type: proto.ColumnType_STRING, Description: "The full name of the repository, including the owner and repo name.",

cloudql/github/table_github_repository_dependabot_alert.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ func tableGitHubRepositoryDependabotAlert() *plugin.Table {
2323
Columns: commonColumns(append(
2424
gitHubDependabotAlertColumns(),
2525
[]*plugin.Column{
26+
{
27+
Name: "repository_id",
28+
Type: proto.ColumnType_INT,
29+
Transform: transform.FromField("Description.RepositoryID"),
30+
Description: "Unique identifier of the GitHub repository.",
31+
},
2632
{
2733
Name: "repository_full_name",
2834
Type: proto.ColumnType_STRING,

cloudql/github/table_github_repository_deployment.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import (
1010

1111
func gitHubRepositoryDeploymentColumns() []*plugin.Column {
1212
return []*plugin.Column{
13+
{
14+
Name: "repository_id",
15+
Type: proto.ColumnType_INT,
16+
Transform: transform.FromField("Description.RepositoryID"),
17+
Description: "Unique identifier of the GitHub repository.",
18+
},
1319
{Name: "repository_full_name", Type: proto.ColumnType_STRING,
1420
Transform: transform.FromField("Description.RepoFullName"),
1521
Description: "The full name of the repository (login/repo-name)."},

cloudql/github/table_github_repository_environment.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import (
1010

1111
func gitHubRepositoryEnvironmentColumns() []*plugin.Column {
1212
return []*plugin.Column{
13+
{
14+
Name: "repository_id",
15+
Type: proto.ColumnType_INT,
16+
Transform: transform.FromField("Description.RepositoryID"),
17+
Description: "Unique identifier of the GitHub repository.",
18+
},
1319
{Name: "repository_full_name", Type: proto.ColumnType_STRING,
1420
Transform: transform.FromField("Description.RepoFullName"),
1521
Description: "The full name of the repository (login/repo-name)."},

cloudql/github/table_github_repository_ruleset.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ func tableGitHubRepositoryRuleset() *plugin.Table {
2525

2626
func gitHubRulesetColumns() []*plugin.Column {
2727
return []*plugin.Column{
28+
{
29+
Name: "repository_id",
30+
Type: proto.ColumnType_INT,
31+
Transform: transform.FromField("Description.RepositoryID"),
32+
Description: "Unique identifier of the GitHub repository.",
33+
},
2834
{Name: "repository_full_name",
2935
Type: proto.ColumnType_STRING,
3036
Transform: transform.FromField("Description.RepoFullName"),

cloudql/github/table_github_repository_sbom.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ func tableGitHubRepositorySbom() *plugin.Table {
1515
Hydrate: opengovernance.ListRepoSBOM,
1616
},
1717
Columns: commonColumns([]*plugin.Column{
18+
{
19+
Name: "repository_id",
20+
Type: proto.ColumnType_INT,
21+
Transform: transform.FromField("Description.RepositoryID"),
22+
Description: "Unique identifier of the GitHub repository.",
23+
},
1824
{
1925
Name: "repository_full_name",
2026
Type: proto.ColumnType_STRING,

cloudql/github/table_github_repository_vulnerability_alert.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ func tableGitHubRepositoryVulnerabilityAlert() *plugin.Table {
2020

2121
func gitHubRepositoryVulnerabilityAlertColumns() []*plugin.Column {
2222
return []*plugin.Column{
23+
{
24+
Name: "repository_id",
25+
Type: proto.ColumnType_INT,
26+
Transform: transform.FromField("Description.RepositoryID"),
27+
Description: "Unique identifier of the GitHub repository.",
28+
},
2329
{Name: "repository_full_name", Type: proto.ColumnType_STRING,
2430
Description: "The full name of the repository, including the owner and repo name.",
2531
Transform: transform.FromField("Description.RepositoryFullName")},

cloudql/github/table_github_repository_webhook.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ func tableGithubRepositoryWebhook() *plugin.Table {
1919
Hydrate: opengovernance.GetWebhook,
2020
},
2121
Columns: commonColumns([]*plugin.Column{
22+
{
23+
Name: "repository_id",
24+
Type: proto.ColumnType_INT,
25+
Transform: transform.FromField("Description.RepositoryID"),
26+
Description: "Unique identifier of the GitHub repository.",
27+
},
2228
{
2329
Name: "id",
2430
Type: proto.ColumnType_INT,

discovery/describers/repository_collaborators.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ func GetAllRepositoriesCollaborators(ctx context.Context, githubClient model.Git
2828
if org != nil && org.ID != nil {
2929
orgId = *org.ID
3030
}
31-
repoValues, err := GetRepositoryCollaborators(ctx, githubClient, stream, organizationName, orgId, repositoryName)
31+
repo, err := getRepositoryDetails(ctx, githubClient.RestClient, organizationName, repositoryName)
32+
if err != nil {
33+
return nil, err
34+
}
35+
repoValues, err := GetRepositoryCollaborators(ctx, githubClient, stream, organizationName, orgId, repositoryName, repo.GetID())
3236
if err != nil {
3337
return nil, err
3438
}
@@ -50,7 +54,7 @@ func GetAllRepositoriesCollaborators(ctx context.Context, githubClient model.Git
5054
if org != nil && org.ID != nil {
5155
orgId = *org.ID
5256
}
53-
repoValues, err := GetRepositoryCollaborators(ctx, githubClient, stream, organizationName, orgId, repo.GetName())
57+
repoValues, err := GetRepositoryCollaborators(ctx, githubClient, stream, organizationName, orgId, repo.GetName(), repo.GetID())
5458
if err != nil {
5559
return nil, err
5660
}
@@ -60,7 +64,7 @@ func GetAllRepositoriesCollaborators(ctx context.Context, githubClient model.Git
6064
return values, nil
6165
}
6266

63-
func GetRepositoryCollaborators(ctx context.Context, githubClient model.GitHubClient, stream *models.StreamSender, owner string, orgId int64, repo string) ([]models.Resource, error) {
67+
func GetRepositoryCollaborators(ctx context.Context, githubClient model.GitHubClient, stream *models.StreamSender, owner string, orgId int64, repo string, repoId int64) ([]models.Resource, error) {
6468
client := githubClient.GraphQLClient
6569
affiliation := githubv4.CollaboratorAffiliationAll
6670
var query struct {
@@ -97,6 +101,7 @@ func GetRepositoryCollaborators(ctx context.Context, githubClient model.GitHubCl
97101
ID: id,
98102
Name: collaborator.Node.Name,
99103
Description: model.RepoCollaboratorsDescription{
104+
RepositoryID: repoId,
100105
RepositoryName: repo,
101106
RepoFullName: repoFullName,
102107
CollaboratorID: collaborator.Node.Login,

0 commit comments

Comments
 (0)