Skip to content

Commit

Permalink
fix: remove issue comments
Browse files Browse the repository at this point in the history
  • Loading branch information
artaasadi committed Dec 4, 2024
1 parent d83c4b1 commit 7de6609
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 446 deletions.
245 changes: 0 additions & 245 deletions pkg/sdk/es/resources_clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -2441,251 +2441,6 @@ func GetIssue(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (

// ========================== END: Issue =============================

// ========================== START: IssueComment =============================

type IssueComment struct {
ResourceID string `json:"resource_id"`
PlatformID string `json:"platform_id"`
Description github.IssueCommentDescription `json:"description"`
Metadata github.Metadata `json:"metadata"`
DescribedBy string `json:"described_by"`
ResourceType string `json:"resource_type"`
IntegrationType string `json:"integration_type"`
IntegrationID string `json:"integration_id"`
}

type IssueCommentHit struct {
ID string `json:"_id"`
Score float64 `json:"_score"`
Index string `json:"_index"`
Type string `json:"_type"`
Version int64 `json:"_version,omitempty"`
Source IssueComment `json:"_source"`
Sort []interface{} `json:"sort"`
}

type IssueCommentHits struct {
Total essdk.SearchTotal `json:"total"`
Hits []IssueCommentHit `json:"hits"`
}

type IssueCommentSearchResponse struct {
PitID string `json:"pit_id"`
Hits IssueCommentHits `json:"hits"`
}

type IssueCommentPaginator struct {
paginator *essdk.BaseESPaginator
}

func (k Client) NewIssueCommentPaginator(filters []essdk.BoolFilter, limit *int64) (IssueCommentPaginator, error) {
paginator, err := essdk.NewPaginator(k.ES(), "github_issue_comment", filters, limit)
if err != nil {
return IssueCommentPaginator{}, err
}

p := IssueCommentPaginator{
paginator: paginator,
}

return p, nil
}

func (p IssueCommentPaginator) HasNext() bool {
return !p.paginator.Done()
}

func (p IssueCommentPaginator) Close(ctx context.Context) error {
return p.paginator.Deallocate(ctx)
}

func (p IssueCommentPaginator) NextPage(ctx context.Context) ([]IssueComment, error) {
var response IssueCommentSearchResponse
err := p.paginator.Search(ctx, &response)
if err != nil {
return nil, err
}

var values []IssueComment
for _, hit := range response.Hits.Hits {
values = append(values, hit.Source)
}

hits := int64(len(response.Hits.Hits))
if hits > 0 {
p.paginator.UpdateState(hits, response.Hits.Hits[hits-1].Sort, response.PitID)
} else {
p.paginator.UpdateState(hits, nil, "")
}

return values, nil
}

var listIssueCommentFilters = map[string]string{
"author": "Description.Author",
"author_association": "Description.AuthorAssociation",
"author_login": "Description.AuthorLogin",
"body": "Description.Body",
"body_text": "Description.BodyText",
"can_delete": "Description.CanDelete",
"can_minimize": "Description.CanMinimize",
"can_react": "Description.CanReact",
"can_update": "Description.CanUpdate",
"cannot_update_reasons": "Description.CannotUpdateReasons",
"created_via_email": "Description.CreatedViaEmail",
"did_author": "Description.DidAuthor",
"editor": "Description.Editor",
"editor_login": "Description.EditorLogin",
"id": "Description.Id",
"includes_created_edit": "Description.IncludesCreatedEdit",
"is_minimized": "Description.IsMinimized",
"minimized_reason": "Description.MinimizedReason",
"node_id": "Description.NodeId",
"number": "Description.Number",
"repository_full_name": "Description.RepoFullName",
"url": "Description.Url",
}

func ListIssueComment(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
plugin.Logger(ctx).Trace("ListIssueComment")
runtime.GC()

// create service
cfg := essdk.GetConfig(d.Connection)
ke, err := essdk.NewClientCached(cfg, d.ConnectionCache, ctx)
if err != nil {
plugin.Logger(ctx).Error("ListIssueComment NewClientCached", "error", err)
return nil, err
}
k := Client{Client: ke}

sc, err := steampipesdk.NewSelfClientCached(ctx, d.ConnectionCache)
if err != nil {
plugin.Logger(ctx).Error("ListIssueComment NewSelfClientCached", "error", err)
return nil, err
}
accountId, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyAccountID)
if err != nil {
plugin.Logger(ctx).Error("ListIssueComment GetConfigTableValueOrNil for OpenGovernanceConfigKeyAccountID", "error", err)
return nil, err
}
encodedResourceCollectionFilters, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyResourceCollectionFilters)
if err != nil {
plugin.Logger(ctx).Error("ListIssueComment GetConfigTableValueOrNil for OpenGovernanceConfigKeyResourceCollectionFilters", "error", err)
return nil, err
}
clientType, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyClientType)
if err != nil {
plugin.Logger(ctx).Error("ListIssueComment GetConfigTableValueOrNil for OpenGovernanceConfigKeyClientType", "error", err)
return nil, err
}

paginator, err := k.NewIssueCommentPaginator(essdk.BuildFilter(ctx, d.QueryContext, listIssueCommentFilters, "github", accountId, encodedResourceCollectionFilters, clientType), d.QueryContext.Limit)
if err != nil {
plugin.Logger(ctx).Error("ListIssueComment NewIssueCommentPaginator", "error", err)
return nil, err
}

for paginator.HasNext() {
page, err := paginator.NextPage(ctx)
if err != nil {
plugin.Logger(ctx).Error("ListIssueComment paginator.NextPage", "error", err)
return nil, err
}

for _, v := range page {
d.StreamListItem(ctx, v)
}
}

err = paginator.Close(ctx)
if err != nil {
return nil, err
}

return nil, nil
}

var getIssueCommentFilters = map[string]string{
"author": "Description.Author",
"author_association": "Description.AuthorAssociation",
"author_login": "Description.AuthorLogin",
"body": "Description.Body",
"body_text": "Description.BodyText",
"can_delete": "Description.CanDelete",
"can_minimize": "Description.CanMinimize",
"can_react": "Description.CanReact",
"can_update": "Description.CanUpdate",
"cannot_update_reasons": "Description.CannotUpdateReasons",
"created_via_email": "Description.CreatedViaEmail",
"did_author": "Description.DidAuthor",
"editor": "Description.Editor",
"editor_login": "Description.EditorLogin",
"id": "Description.Id",
"includes_created_edit": "Description.IncludesCreatedEdit",
"is_minimized": "Description.IsMinimized",
"minimized_reason": "Description.MinimizedReason",
"node_id": "Description.NodeId",
"number": "Description.Number",
"repository_full_name": "Description.RepoFullName",
"url": "Description.Url",
}

func GetIssueComment(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
plugin.Logger(ctx).Trace("GetIssueComment")
runtime.GC()
// create service
cfg := essdk.GetConfig(d.Connection)
ke, err := essdk.NewClientCached(cfg, d.ConnectionCache, ctx)
if err != nil {
return nil, err
}
k := Client{Client: ke}

sc, err := steampipesdk.NewSelfClientCached(ctx, d.ConnectionCache)
if err != nil {
return nil, err
}
accountId, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyAccountID)
if err != nil {
return nil, err
}
encodedResourceCollectionFilters, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyResourceCollectionFilters)
if err != nil {
return nil, err
}
clientType, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyClientType)
if err != nil {
return nil, err
}

limit := int64(1)
paginator, err := k.NewIssueCommentPaginator(essdk.BuildFilter(ctx, d.QueryContext, getIssueCommentFilters, "github", accountId, encodedResourceCollectionFilters, clientType), &limit)
if err != nil {
return nil, err
}

for paginator.HasNext() {
page, err := paginator.NextPage(ctx)
if err != nil {
return nil, err
}

for _, v := range page {
return v, nil
}
}

err = paginator.Close(ctx)
if err != nil {
return nil, err
}

return nil, nil
}

// ========================== END: IssueComment =============================

// ========================== START: License =============================

type License struct {
Expand Down
14 changes: 0 additions & 14 deletions provider/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,6 @@ var ResourceTypes = map[string]model.ResourceType{
GetDescriber: DescribeSingleByRepo(describer.GetIssue),
},

"Github/Issue/Comment": {
IntegrationType: configs.IntegrationName,
ResourceName: "Github/Issue/Comment",
Tags: map[string][]string{
"category": {"Issue"},
},
Labels: map[string]string{
},
Annotations: map[string]string{
},
ListDescriber: DescribeByGithub(describer.GetAllIssueComments),
GetDescriber: nil,
},

"Github/License": {
IntegrationType: configs.IntegrationName,
ResourceName: "Github/License",
Expand Down
12 changes: 0 additions & 12 deletions provider/resource_types/resource-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,6 @@
"SteampipeTable": "github_issue",
"Model": "Issue"
},
{
"ResourceName": "Github/Issue/Comment",
"Tags": {
"category": [
"Issue"
]
},
"ListDescriber": "DescribeByGithub(describer.GetAllIssueComments)",
"GetDescriber": "",
"SteampipeTable": "github_issue_comment",
"Model": "IssueComment"
},
{
"ResourceName": "Github/License",
"Tags": {
Expand Down
1 change: 0 additions & 1 deletion steampipe-plugin-github/github/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"github_community_profile": tableGitHubCommunityProfile(),
"github_gitignore": tableGitHubGitignore(),
"github_issue": tableGitHubIssue(),
"github_issue_comment": tableGitHubIssueComment(),
"github_license": tableGitHubLicense(),
"github_organization": tableGitHubOrganization(),
"github_organization_dependabot_alert": tableGitHubOrganizationDependabotAlert(),
Expand Down
Loading

0 comments on commit 7de6609

Please sign in to comment.