-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathtable_github_community_profile.go
More file actions
64 lines (54 loc) · 3.11 KB
/
Copy pathtable_github_community_profile.go
File metadata and controls
64 lines (54 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package github
import (
"context"
"github.com/shurcooL/githubv4"
"github.com/turbot/steampipe-plugin-github/github/models"
"github.com/turbot/steampipe-plugin-sdk/v6/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v6/plugin"
"github.com/turbot/steampipe-plugin-sdk/v6/plugin/transform"
)
func tableGitHubCommunityProfile() *plugin.Table {
return &plugin.Table{
Name: "github_community_profile",
Description: "Community profile information for the given repository.",
List: &plugin.ListConfig{
KeyColumns: plugin.SingleColumn("repository_full_name"),
Hydrate: tableGitHubCommunityProfileList,
ShouldIgnoreError: isNotFoundError([]string{"404"}),
},
Columns: commonColumns([]*plugin.Column{
{Name: "repository_full_name", Type: proto.ColumnType_STRING, Transform: transform.FromQual("repository_full_name"), Description: "Full name of the repository that contains the tag."},
{Name: "code_of_conduct", Type: proto.ColumnType_JSON, Transform: transform.FromValue().NullIfZero(), Hydrate: cpHydrateCodeOfConduct, Description: "Code of conduct for the repository."},
{Name: "contributing", Type: proto.ColumnType_JSON, Transform: transform.FromValue().NullIfZero(), Hydrate: cpHydrateContributing, Description: "Contributing guidelines for the repository."},
{Name: "issue_templates", Type: proto.ColumnType_JSON, Transform: transform.FromValue().NullIfZero(), Hydrate: cpHydrateIssueTemplates, Description: "Issue template for the repository."},
{Name: "pull_request_templates", Type: proto.ColumnType_JSON, Transform: transform.FromValue().NullIfZero(), Hydrate: cpHydratePullRequestTemplates, Description: "Pull request template for the repository."},
{Name: "license_info", Type: proto.ColumnType_JSON, Transform: transform.FromValue().NullIfZero(), Hydrate: cpHydrateLicense, Description: "License for the repository."},
{Name: "readme", Type: proto.ColumnType_JSON, Transform: transform.FromValue().NullIfZero(), Hydrate: cpHydrateReadme, Description: "README for the repository."},
{Name: "security", Type: proto.ColumnType_JSON, Transform: transform.FromValue().NullIfZero(), Hydrate: cpHydrateSecurity, Description: "Security for the repository."},
}),
}
}
func tableGitHubCommunityProfileList(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
fullName := d.EqualsQuals["repository_full_name"].GetStringValue()
owner, repo := parseRepoFullName(fullName)
var query struct {
RateLimit models.RateLimit
Repository struct {
models.CommunityProfile
} `graphql:"repository(owner: $owner, name: $repo)"`
}
variables := map[string]interface{}{
"owner": githubv4.String(owner),
"repo": githubv4.String(repo),
}
appendCommunityProfileColumnIncludes(&variables, d.QueryContext.Columns)
client := connectV4(ctx, d)
err := client.Query(ctx, &query, variables)
plugin.Logger(ctx).Debug(rateLimitLogString("github_community_profile", &query.RateLimit))
if err != nil {
plugin.Logger(ctx).Error("github_community_profile", "api_error", err)
return nil, err
}
d.StreamListItem(ctx, query.Repository.CommunityProfile)
return nil, nil
}