Skip to content

Commit d8bd443

Browse files
committed
fix: add organization and repo tables
1 parent 04bef79 commit d8bd443

14 files changed

+2603
-312
lines changed

cloudql/github/plugin.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,21 @@ func Plugin(ctx context.Context) *plugin.Plugin {
5555
"github_team_member": tableGitHubTeamMember(),
5656
"github_team_repository": tableGitHubTeamRepository(),
5757
//"github_tree": tableGitHubTree(),
58-
"github_user": tableGitHubUser(),
59-
"github_workflow": tableGitHubWorkflow(),
60-
"github_container_package": tableGitHubContainerPackage(),
61-
"github_maven_package": tableGitHubMavenPackage(),
62-
"github_npm_package": tableGitHubNPMPackage(),
63-
"github_nuget_package": tableGitHubNugetPackage(),
64-
"github_artifact_dockerfile": tableGitHubArtifactDockerFile(),
65-
"github_repository_webhook": tableGithubRepositoryWebhook(),
66-
"github_artifact_ai_model": tableGitHubArtifactAIModel(),
67-
"github_organization_role": tableGitHubOrganizationRole(),
68-
"github_organization_app": tableGitHubOrganizationApp(),
69-
"github_organization_token": tableGitHubOrganizationToken(),
58+
"github_user": tableGitHubUser(),
59+
"github_workflow": tableGitHubWorkflow(),
60+
"github_container_package": tableGitHubContainerPackage(),
61+
"github_maven_package": tableGitHubMavenPackage(),
62+
"github_npm_package": tableGitHubNPMPackage(),
63+
"github_nuget_package": tableGitHubNugetPackage(),
64+
"github_artifact_dockerfile": tableGitHubArtifactDockerFile(),
65+
"github_repository_webhook": tableGithubRepositoryWebhook(),
66+
"github_artifact_ai_model": tableGitHubArtifactAIModel(),
67+
"github_organization_role": tableGitHubOrganizationRole(),
68+
"github_organization_app": tableGitHubOrganizationApp(),
69+
"github_organization_token": tableGitHubOrganizationToken(),
70+
"github_repository_permission": tableGitHubRepositoryPermission(),
71+
"github_organization_role_assignment": tableGitHubOrganizationRoleAssignment(),
72+
"github_organization_role_definition": tableGitHubOrganizationRoleDefinition(),
7073
},
7174
}
7275
for key, table := range p.TableMap {
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package github
2+
3+
import (
4+
opengovernance "github.com/opengovern/og-describer-github/discovery/pkg/es"
5+
6+
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
7+
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
8+
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
9+
)
10+
11+
func gitHubOrganizationRoleAssignment() []*plugin.Column {
12+
tableCols := []*plugin.Column{
13+
{
14+
Name: "role_id",
15+
Type: proto.ColumnType_INT,
16+
Description: "Affiliation filter - valid values 'ALL' (default), 'OUTSIDE', 'DIRECT'.",
17+
Transform: transform.FromField("Description.RoleId")},
18+
{
19+
Name: "organization_id",
20+
Type: proto.ColumnType_INT,
21+
Description: "The name of the repository",
22+
Transform: transform.FromField("Description.OrganizationId")},
23+
24+
{
25+
Name: "list_of_teams",
26+
Type: proto.ColumnType_JSON,
27+
Description: "The permission the collaborator has on the repository.",
28+
Transform: transform.FromField("Description.ListOfTeams")},
29+
30+
{
31+
Name: "list_of_users",
32+
Type: proto.ColumnType_JSON,
33+
Description: "The login details of the collaborator.",
34+
Transform: transform.FromField("Description.ListOfUsers")},
35+
{
36+
Name: "created_at",
37+
Type: proto.ColumnType_TIMESTAMP,
38+
Description: "The id of the collaborator.",
39+
Transform: transform.FromField("Description.CreatedAt")},
40+
{
41+
Name: "updated_at",
42+
Type: proto.ColumnType_TIMESTAMP,
43+
Description: "The id of the collaborator.",
44+
Transform: transform.FromField("Description.UpdatedAt")},
45+
}
46+
47+
return tableCols
48+
}
49+
50+
func tableGitHubOrganizationRoleAssignment() *plugin.Table {
51+
return &plugin.Table{
52+
Name: "github_organization_role_assignment",
53+
Description: "GitHub members for a given organization. GitHub Users are user accounts in GitHub.",
54+
List: &plugin.ListConfig{
55+
Hydrate: opengovernance.ListOrganizationRoleAssignment,
56+
},
57+
Columns: commonColumns(gitHubOrganizationRoleAssignment()),
58+
}
59+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package github
2+
3+
import (
4+
opengovernance "github.com/opengovern/og-describer-github/discovery/pkg/es"
5+
6+
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
7+
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
8+
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
9+
)
10+
11+
func gitHubOrganizationRoleDefinition() []*plugin.Column {
12+
tableCols := []*plugin.Column{
13+
{
14+
Name: "id",
15+
Type: proto.ColumnType_INT,
16+
Description: "Affiliation filter - valid values 'ALL' (default), 'OUTSIDE', 'DIRECT'.",
17+
Transform: transform.FromField("Description.Id")},
18+
{
19+
Name: "name",
20+
Type: proto.ColumnType_STRING,
21+
Description: "Affiliation filter - valid values 'ALL' (default), 'OUTSIDE', 'DIRECT'.",
22+
Transform: transform.FromField("Description.Name")},
23+
{
24+
Name: "description",
25+
Type: proto.ColumnType_STRING,
26+
Description: "Affiliation filter - valid values 'ALL' (default), 'OUTSIDE', 'DIRECT'.",
27+
Transform: transform.FromField("Description.Description")},
28+
{
29+
Name: "permissions",
30+
Type: proto.ColumnType_JSON,
31+
Description: "Affiliation filter - valid values 'ALL' (default), 'OUTSIDE', 'DIRECT'.",
32+
Transform: transform.FromField("Description.Permissions")},
33+
{
34+
Name: "organization_id",
35+
Type: proto.ColumnType_INT,
36+
Description: "The name of the repository",
37+
Transform: transform.FromField("Description.OrganizationId")},
38+
{
39+
Name: "created_at",
40+
Type: proto.ColumnType_TIMESTAMP,
41+
Description: "The permission the collaborator has on the repository.",
42+
Transform: transform.FromField("Description.CreatedAt")},
43+
{
44+
Name: "updated_at",
45+
Type: proto.ColumnType_TIMESTAMP,
46+
Description: "The permission the collaborator has on the repository.",
47+
Transform: transform.FromField("Description.UpdatedAt")},
48+
{
49+
Name: "source",
50+
Type: proto.ColumnType_STRING,
51+
Description: "The login details of the collaborator.",
52+
Transform: transform.FromField("Description.Source")},
53+
{
54+
Name: "base_role",
55+
Type: proto.ColumnType_STRING,
56+
Description: "The login details of the collaborator.",
57+
Transform: transform.FromField("Description.BaseRole")},
58+
{
59+
Name: "type",
60+
Type: proto.ColumnType_STRING,
61+
Description: "The login details of the collaborator.",
62+
Transform: transform.FromField("Description.Type")},
63+
}
64+
65+
return tableCols
66+
}
67+
68+
func tableGitHubOrganizationRoleDefinition() *plugin.Table {
69+
return &plugin.Table{
70+
Name: "github_organization_role_definition",
71+
Description: "GitHub members for a given organization. GitHub Users are user accounts in GitHub.",
72+
List: &plugin.ListConfig{
73+
Hydrate: opengovernance.ListOrganizationRoleDefinition,
74+
},
75+
Columns: commonColumns(gitHubOrganizationRoleDefinition()),
76+
}
77+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package github
2+
3+
import (
4+
opengovernance "github.com/opengovern/og-describer-github/discovery/pkg/es"
5+
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
6+
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
7+
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
8+
)
9+
10+
func tableGitHubRepositoryPermission() *plugin.Table {
11+
return &plugin.Table{
12+
Name: "github_repository_permission",
13+
Description: "Get the software bill of materials (SBOM) for a repository.",
14+
List: &plugin.ListConfig{
15+
Hydrate: opengovernance.ListRepositoryPermission,
16+
},
17+
Columns: commonColumns([]*plugin.Column{
18+
{
19+
Name: "principal_name",
20+
Type: proto.ColumnType_STRING,
21+
Transform: transform.FromField("Description.PrincipalName"),
22+
Description: "The full name of the repository (login/repo-name).",
23+
},
24+
{
25+
Name: "principal_id",
26+
Type: proto.ColumnType_INT,
27+
Transform: transform.FromField("Description.PrincipalId"),
28+
Description: "The full name of the repository (login/repo-name).",
29+
},
30+
{
31+
Name: "principal_type",
32+
Type: proto.ColumnType_STRING,
33+
Transform: transform.FromField("Description.PrincipalType"),
34+
Description: "The full name of the repository (login/repo-name).",
35+
},
36+
{
37+
Name: "repository_name",
38+
Type: proto.ColumnType_STRING,
39+
Transform: transform.FromField("Description.RepositoryName"),
40+
Description: "The full name of the repository (login/repo-name).",
41+
},
42+
{
43+
Name: "repository_full_name",
44+
Type: proto.ColumnType_STRING,
45+
Transform: transform.FromField("Description.RepositoryFullName"),
46+
Description: "The full name of the repository (login/repo-name).",
47+
},
48+
{
49+
Name: "repository_id",
50+
Type: proto.ColumnType_INT,
51+
Transform: transform.FromField("Description.RepositoryId"),
52+
Description: "The full name of the repository (login/repo-name).",
53+
},
54+
{
55+
Name: "permissions",
56+
Type: proto.ColumnType_JSON,
57+
Transform: transform.FromField("Description.Permissions"),
58+
Description: "The full name of the repository (login/repo-name).",
59+
},
60+
{
61+
Name: "role_name",
62+
Type: proto.ColumnType_STRING,
63+
Transform: transform.FromField("Description.RoleName"),
64+
Description: "The full name of the repository (login/repo-name).",
65+
},
66+
}),
67+
}
68+
}

cloudql/github/table_github_user.go

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,49 +20,29 @@ func tableGitHubUser() *plugin.Table {
2020
}
2121

2222
func tableGitHubUserColumns() []*plugin.Column {
23-
cols := sharedUserColumns()
24-
25-
counts := []*plugin.Column{
26-
{Name: "repositories_total_disk_usage", Type: proto.ColumnType_INT, Description: "Total disk spaced used by the users repositories.",
27-
Transform: transform.FromField("Description.RepositoriesTotalDiskUsage")},
28-
{Name: "followers_total_count", Type: proto.ColumnType_INT, Description: "Count of how many users this user follows.",
29-
Transform: transform.FromField("Description.FollowersTotalCount")},
30-
{Name: "following_total_count", Type: proto.ColumnType_INT, Description: "Count of how many users follow this user.",
31-
Transform: transform.FromField("Description.FollowingTotalCount")},
32-
{Name: "public_repositories_total_count", Type: proto.ColumnType_INT, Description: "Count of public repositories for the user.",
33-
Transform: transform.FromField("Description.PublicRepositoriesTotalCount")},
34-
{Name: "private_repositories_total_count", Type: proto.ColumnType_INT, Description: "Count of private repositories for the user.",
35-
Transform: transform.FromField("Description.PrivateRepositoriesTotalCount")},
36-
{Name: "public_gists_total_count", Type: proto.ColumnType_INT, Description: "Count of public gists for the user.",
37-
Transform: transform.FromField("Description.PublicGistsTotalCount")},
38-
{Name: "issues_total_count", Type: proto.ColumnType_INT, Description: "Count of issues associated with the user.",
39-
Transform: transform.FromField("Description.IssuesTotalCount")},
40-
{Name: "organizations_total_count", Type: proto.ColumnType_INT, Description: "Count of organizations the user belongs to.",
41-
Transform: transform.FromField("Description.OrganizationsTotalCount")},
42-
{Name: "public_keys_total_count", Type: proto.ColumnType_INT, Description: "Count of public keys associated with the user.",
43-
Transform: transform.FromField("Description.PublicKeysTotalCount")},
44-
{Name: "open_pull_requests_total_count", Type: proto.ColumnType_INT, Description: "Count of open pull requests associated with the user.",
45-
Transform: transform.FromField("Description.OpenPullRequestsTotalCount")},
46-
{Name: "merged_pull_requests_total_count", Type: proto.ColumnType_INT, Description: "Count of merged pull requests associated with the user.",
47-
Transform: transform.FromField("Description.MergedPullRequestsTotalCount")},
48-
{Name: "closed_pull_requests_total_count", Type: proto.ColumnType_INT, Description: "Count of closed pull requests associated with the user.",
49-
Transform: transform.FromField("Description.ClosedPullRequestsTotalCount")},
50-
{Name: "packages_total_count", Type: proto.ColumnType_INT, Description: "Count of packages hosted by the user.",
51-
Transform: transform.FromField("Description.PackagesTotalCount")},
52-
{Name: "pinned_items_total_count", Type: proto.ColumnType_INT, Description: "Count of items pinned on the users profile.",
53-
Transform: transform.FromField("Description.PinnedItemsTotalCount")},
54-
{Name: "sponsoring_total_count", Type: proto.ColumnType_INT, Description: "Count of users that this user is sponsoring.",
55-
Transform: transform.FromField("Description.SponsoringTotalCount")},
56-
{Name: "sponsors_total_count", Type: proto.ColumnType_INT, Description: "Count of users sponsoring this user.",
57-
Transform: transform.FromField("Description.SponsorsTotalCount")},
58-
{Name: "starred_repositories_total_count", Type: proto.ColumnType_INT, Description: "Count of repositories the user has starred.",
59-
Transform: transform.FromField("Description.StarredRepositoriesTotalCount")},
60-
{Name: "watching_total_count", Type: proto.ColumnType_INT, Description: "Count of repositories being watched by the user.",
61-
Transform: transform.FromField("Description.WatchingTotalCount")},
23+
cols := []*plugin.Column{
24+
{Name: "login", Type: proto.ColumnType_STRING, Description: "Total disk spaced used by the users repositories.",
25+
Transform: transform.FromField("Description.Login")},
26+
{Name: "id", Type: proto.ColumnType_INT, Description: "Total disk spaced used by the users repositories.",
27+
Transform: transform.FromField("Description.ID")},
28+
{Name: "node_id", Type: proto.ColumnType_STRING, Description: "Total disk spaced used by the users repositories.",
29+
Transform: transform.FromField("Description.NodeId")},
30+
{Name: "name", Type: proto.ColumnType_STRING, Description: "Total disk spaced used by the users repositories.",
31+
Transform: transform.FromField("Description.Name")},
32+
{Name: "email", Type: proto.ColumnType_STRING, Description: "Total disk spaced used by the users repositories.",
33+
Transform: transform.FromField("Description.Email")},
34+
{Name: "company", Type: proto.ColumnType_STRING, Description: "Total disk spaced used by the users repositories.",
35+
Transform: transform.FromField("Description.Company")},
36+
{Name: "location", Type: proto.ColumnType_STRING, Description: "Total disk spaced used by the users repositories.",
37+
Transform: transform.FromField("Description.Location")},
38+
{Name: "url", Type: proto.ColumnType_STRING, Description: "Total disk spaced used by the users repositories.",
39+
Transform: transform.FromField("Description.Url")},
40+
{Name: "created_at", Type: proto.ColumnType_TIMESTAMP, Description: "Total disk spaced used by the users repositories.",
41+
Transform: transform.FromField("Description.CreatedAt")},
42+
{Name: "updated_at", Type: proto.ColumnType_TIMESTAMP, Description: "Total disk spaced used by the users repositories.",
43+
Transform: transform.FromField("Description.UpdatedAt")},
6244
}
6345

64-
cols = append(cols, counts...)
65-
6646
return cols
6747
}
6848

0 commit comments

Comments
 (0)