Skip to content

Commit

Permalink
fix: add new tables
Browse files Browse the repository at this point in the history
  • Loading branch information
artaasadi committed Nov 19, 2024
1 parent 0a0ee5e commit 839842a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 44 deletions.
34 changes: 24 additions & 10 deletions steampipe-plugin-github/github/table_github_code_owner.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package github

import (
opengovernance "github.com/opengovern/og-describer-github/pkg/sdk/es"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"

"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
Expand All @@ -10,14 +11,29 @@ import (
func gitHubCodeOwnerColumns() []*plugin.Column {
return []*plugin.Column{
// Top columns
{Name: "repository_full_name", Type: proto.ColumnType_STRING, Description: "The full name of the repository, including the owner and repo name."},
{Name: "repository_full_name", Type: proto.ColumnType_STRING,
Transform: transform.FromField("Description.RepositoryFullName"),
Description: "The full name of the repository, including the owner and repo name."},
// Other columns
{Name: "line", Type: proto.ColumnType_INT, Description: "The rule's line number in the CODEOWNERS file.", Transform: transform.FromField("LineNumber")},
{Name: "pattern", Type: proto.ColumnType_STRING, Description: "The pattern used to identify what code a team, or an individual is responsible for"},
{Name: "users", Type: proto.ColumnType_JSON, Description: "Users responsible for code in the repo"},
{Name: "teams", Type: proto.ColumnType_JSON, Description: "Teams responsible for code in the repo"},
{Name: "pre_comments", Type: proto.ColumnType_JSON, Description: "Specifies the comments added above a key."},
{Name: "line_comment", Type: proto.ColumnType_STRING, Description: "Specifies the comment following the node and before empty lines."},
{Name: "line", Type: proto.ColumnType_INT,
Description: "The rule's line number in the CODEOWNERS file.",
Transform: transform.FromField("Description.LineNumber"),
},
{Name: "pattern", Type: proto.ColumnType_STRING,
Transform: transform.FromField("Description.Pattern"),
Description: "The pattern used to identify what code a team, or an individual is responsible for"},
{Name: "users",
Transform: transform.FromField("Description.Users"),
Type: proto.ColumnType_JSON, Description: "Users responsible for code in the repo"},
{Name: "teams",
Transform: transform.FromField("Description.Teams"),
Type: proto.ColumnType_JSON, Description: "Teams responsible for code in the repo"},
{Name: "pre_comments",
Transform: transform.FromField("Description.PreComments"),
Type: proto.ColumnType_JSON, Description: "Specifies the comments added above a key."},
{Name: "line_comment",
Transform: transform.FromField("Description.LineComment"),
Type: proto.ColumnType_STRING, Description: "Specifies the comment following the node and before empty lines."},
}
}

Expand All @@ -26,9 +42,7 @@ func tableGitHubCodeOwner() *plugin.Table {
Name: "github_code_owner",
Description: "Individuals or teams that are responsible for code in a repository.",
List: &plugin.ListConfig{
Hydrate: tableGitHubCodeOwnerList,
ShouldIgnoreError: isNotFoundError([]string{"404"}),
KeyColumns: plugin.SingleColumn("repository_full_name"),
Hydrate: opengovernance.ListCodeOwner,
},
Columns: commonColumns(gitHubCodeOwnerColumns()),
}
Expand Down
3 changes: 2 additions & 1 deletion steampipe-plugin-github/github/table_github_organization.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package github

import (
opengovernance "github.com/opengovern/og-describer-github/pkg/sdk/es"
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
Expand Down Expand Up @@ -340,7 +341,7 @@ func tableGitHubOrganization() *plugin.Table {
Name: "github_organization",
Description: "GitHub Organizations are shared accounts where businesses and open-source projects can collaborate across many projects at once.",
List: &plugin.ListConfig{
Hydrate: tableGitHubOrganizationList,
Hydrate: opengovernance.ListOrganization,
},
Columns: commonColumns(gitHubOrganizationColumns()),
}
Expand Down
64 changes: 31 additions & 33 deletions steampipe-plugin-github/github/table_github_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,65 +10,65 @@ import (
func gitHubTeamColumns() []*plugin.Column {
return []*plugin.Column{
{Name: "organization", Type: proto.ColumnType_STRING, Description: "The organization the team is associated with.",
Transform: transform.FromField("Organization.Organization")},
Transform: transform.FromField("Description.Organization")},
{Name: "slug",
Transform: transform.FromField("Organization.Slug"),
Transform: transform.FromField("Description.Slug"),
Type: proto.ColumnType_STRING, Description: "The team slug name."},
{Name: "name",
Transform: transform.FromField("Organization.Name"),
Transform: transform.FromField("Description.Name"),
Type: proto.ColumnType_STRING, Description: "The name of the team."},
{Name: "id", Type: proto.ColumnType_INT, Description: "The ID of the team.",
Transform: transform.FromField("Organization.ID")},
Transform: transform.FromField("Description.ID")},
{Name: "node_id", Type: proto.ColumnType_STRING, Description: "The node id of the team.",
Transform: transform.FromField("Organization.NodeID")},
Transform: transform.FromField("Description.NodeID")},
{Name: "description", Type: proto.ColumnType_STRING, Description: "The description of the team.",
Transform: transform.FromField("Organization.Description")},
Transform: transform.FromField("Description.Description")},
{Name: "created_at", Type: proto.ColumnType_TIMESTAMP, Description: "Timestamp when team was created.",
Transform: transform.FromField("Organization.CreatedAt").Transform(convertTimestamp)},
Transform: transform.FromField("Description.CreatedAt").Transform(convertTimestamp)},
{Name: "updated_at", Type: proto.ColumnType_TIMESTAMP, Description: "Timestamp when team was last updated.",
Transform: transform.FromField("Organization.UpdatedAt").Transform(convertTimestamp)},
Transform: transform.FromField("Description.UpdatedAt").Transform(convertTimestamp)},
{Name: "combined_slug", Type: proto.ColumnType_STRING, Description: "The slug corresponding to the organization and the team.",
Transform: transform.FromField("Organization.CombinedSlug")},
Transform: transform.FromField("Description.CombinedSlug")},
{Name: "parent_team", Type: proto.ColumnType_JSON, Description: "The teams parent team.",
Transform: transform.FromField("Organization.ParentTeam")},
Transform: transform.FromField("Description.ParentTeam")},
{Name: "privacy", Type: proto.ColumnType_STRING, Description: "The privacy setting of the team (VISIBLE or SECRET).",
Transform: transform.FromField("Organization.Privacy")},
Transform: transform.FromField("Description.Privacy")},
{Name: "ancestors_total_count", Type: proto.ColumnType_INT, Description: "Count of ancestors this team has.",
Transform: transform.FromField("Organization.AncestorsTotalCount")},
Transform: transform.FromField("Description.AncestorsTotalCount")},
{Name: "child_teams_total_count", Type: proto.ColumnType_INT, Description: "Count of children teams this team has.",
Transform: transform.FromField("Organization.ChildTeamsTotalCount")},
Transform: transform.FromField("Description.ChildTeamsTotalCount")},
{Name: "discussions_total_count", Type: proto.ColumnType_INT, Description: "Count of team discussions.",
Transform: transform.FromField("Organization.DiscussionsTotalCount")},
Transform: transform.FromField("Description.DiscussionsTotalCount")},
{Name: "invitations_total_count", Type: proto.ColumnType_INT, Description: "Count of outstanding team member invitations for the team.",
Transform: transform.FromField("Organization.InvitationsTotalCount")},
Transform: transform.FromField("Description.InvitationsTotalCount")},
{Name: "members_total_count", Type: proto.ColumnType_INT, Description: "Count of team members.",
Transform: transform.FromField("Organization.MembersTotalCount")},
Transform: transform.FromField("Description.MembersTotalCount")},
{Name: "projects_v2_total_count", Type: proto.ColumnType_INT, Description: "Count of the teams v2 projects.",
Transform: transform.FromField("Organization.ProjectsV2TotalCount")},
Transform: transform.FromField("Description.ProjectsV2TotalCount")},
{Name: "repositories_total_count", Type: proto.ColumnType_INT, Description: "Count of repositories the team has.",
Transform: transform.FromField("Organization.RepositoriesTotalCount")},
Transform: transform.FromField("Description.RepositoriesTotalCount")},
{Name: "url", Type: proto.ColumnType_STRING, Description: "URL for the team page in GitHub.",
Transform: transform.FromField("Organization.URL")},
Transform: transform.FromField("Description.URL")},
{Name: "avatar_url", Type: proto.ColumnType_STRING, Description: "URL for teams avatar.",
Transform: transform.FromField("Organization.AvatarURL")},
Transform: transform.FromField("Description.AvatarURL")},
{Name: "discussions_url", Type: proto.ColumnType_STRING, Description: "URL for team discussions.",
Transform: transform.FromField("Organization.DiscussionsURL")},
Transform: transform.FromField("Description.DiscussionsURL")},
{Name: "edit_team_url", Type: proto.ColumnType_STRING, Description: "URL for editing this team.",
Transform: transform.FromField("Organization.EditTeamURL")},
Transform: transform.FromField("Description.EditTeamURL")},
{Name: "members_url", Type: proto.ColumnType_STRING, Description: "URL for team members.",
Transform: transform.FromField("Organization.MembersURL")},
Transform: transform.FromField("Description.MembersURL")},
{Name: "new_team_url", Type: proto.ColumnType_STRING, Description: "The HTTP URL creating a new team.",
Transform: transform.FromField("Organization.NewTeamURL")},
Transform: transform.FromField("Description.NewTeamURL")},
{Name: "repositories_url", Type: proto.ColumnType_STRING, Description: "URL for team repositories.",
Transform: transform.FromField("Organization.RepositoriesURL")},
Transform: transform.FromField("Description.RepositoriesURL")},
{Name: "teams_url", Type: proto.ColumnType_STRING, Description: "URL for this team's teams.",
Transform: transform.FromField("Organization.TeamsURL")},
Transform: transform.FromField("Description.TeamsURL")},
{Name: "can_administer", Type: proto.ColumnType_BOOL, Description: "If true, current user can administer the team.",
Transform: transform.FromField("Organization.CanAdminister")},
Transform: transform.FromField("Description.CanAdminister")},
{Name: "can_subscribe", Type: proto.ColumnType_BOOL, Description: "If true, current user can subscribe to the team.",
Transform: transform.FromField("Organization.CanSubscribe")},
Transform: transform.FromField("Description.CanSubscribe")},
{Name: "subscription", Type: proto.ColumnType_STRING, Description: "Subscription status of the current user to the team.",
Transform: transform.FromField("Organization.Subscription")},
Transform: transform.FromField("Description.Subscription")},
}
}

Expand All @@ -77,14 +77,12 @@ func tableGitHubTeam() *plugin.Table {
Name: "github_team",
Description: "GitHub Teams in a given organization. GitHub Teams are groups of organization members that reflect your company or group's structure with cascading access permissions and mentions.",
List: &plugin.ListConfig{
KeyColumns: plugin.SingleColumn("organization"),
ShouldIgnoreError: isNotFoundError([]string{"404"}),
Hydrate: opengovernance.ListTeamMembers(),
Hydrate: opengovernance.ListTeamMembers,
},
Get: &plugin.GetConfig{
KeyColumns: plugin.AllColumns([]string{"organization", "slug"}),
ShouldIgnoreError: isNotFoundError([]string{"404"}),
Hydrate: tableGitHubTeamGet,
Hydrate: opengovernance.GetTeamMembers,
},
Columns: commonColumns(gitHubTeamColumns()),
}
Expand Down

0 comments on commit 839842a

Please sign in to comment.