diff --git a/pkg/sdk/es/resources_clients.go b/pkg/sdk/es/resources_clients.go index 18fb2833..54b9924a 100644 --- a/pkg/sdk/es/resources_clients.go +++ b/pkg/sdk/es/resources_clients.go @@ -896,221 +896,6 @@ func GetWorkflowRun(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateD // ========================== END: WorkflowRun ============================= -// ========================== START: Blob ============================= - -type Blob struct { - ResourceID string `json:"resource_id"` - PlatformID string `json:"platform_id"` - Description github.BlobDescription `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 BlobHit struct { - ID string `json:"_id"` - Score float64 `json:"_score"` - Index string `json:"_index"` - Type string `json:"_type"` - Version int64 `json:"_version,omitempty"` - Source Blob `json:"_source"` - Sort []interface{} `json:"sort"` -} - -type BlobHits struct { - Total essdk.SearchTotal `json:"total"` - Hits []BlobHit `json:"hits"` -} - -type BlobSearchResponse struct { - PitID string `json:"pit_id"` - Hits BlobHits `json:"hits"` -} - -type BlobPaginator struct { - paginator *essdk.BaseESPaginator -} - -func (k Client) NewBlobPaginator(filters []essdk.BoolFilter, limit *int64) (BlobPaginator, error) { - paginator, err := essdk.NewPaginator(k.ES(), "github_blob", filters, limit) - if err != nil { - return BlobPaginator{}, err - } - - p := BlobPaginator{ - paginator: paginator, - } - - return p, nil -} - -func (p BlobPaginator) HasNext() bool { - return !p.paginator.Done() -} - -func (p BlobPaginator) Close(ctx context.Context) error { - return p.paginator.Deallocate(ctx) -} - -func (p BlobPaginator) NextPage(ctx context.Context) ([]Blob, error) { - var response BlobSearchResponse - err := p.paginator.Search(ctx, &response) - if err != nil { - return nil, err - } - - var values []Blob - 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 listBlobFilters = map[string]string{ - "blob_sha": "Description.SHA", - "content": "Description.Content", - "encoding": "Description.Encoding", - "node_id": "Description.NodeID", - "repository_full_name": "Description.RepoFullName", - "size": "Description.Size", - "url": "Description.URL", -} - -func ListBlob(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { - plugin.Logger(ctx).Trace("ListBlob") - runtime.GC() - - // create service - cfg := essdk.GetConfig(d.Connection) - ke, err := essdk.NewClientCached(cfg, d.ConnectionCache, ctx) - if err != nil { - plugin.Logger(ctx).Error("ListBlob NewClientCached", "error", err) - return nil, err - } - k := Client{Client: ke} - - sc, err := steampipesdk.NewSelfClientCached(ctx, d.ConnectionCache) - if err != nil { - plugin.Logger(ctx).Error("ListBlob NewSelfClientCached", "error", err) - return nil, err - } - integrationID, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyIntegrationID) - if err != nil { - plugin.Logger(ctx).Error("ListBlob GetConfigTableValueOrNil for OpenGovernanceConfigKeyIntegrationID", "error", err) - return nil, err - } - encodedResourceCollectionFilters, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyResourceCollectionFilters) - if err != nil { - plugin.Logger(ctx).Error("ListBlob GetConfigTableValueOrNil for OpenGovernanceConfigKeyResourceCollectionFilters", "error", err) - return nil, err - } - clientType, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyClientType) - if err != nil { - plugin.Logger(ctx).Error("ListBlob GetConfigTableValueOrNil for OpenGovernanceConfigKeyClientType", "error", err) - return nil, err - } - - paginator, err := k.NewBlobPaginator(essdk.BuildFilter(ctx, d.QueryContext, listBlobFilters, integrationID, encodedResourceCollectionFilters, clientType), d.QueryContext.Limit) - if err != nil { - plugin.Logger(ctx).Error("ListBlob NewBlobPaginator", "error", err) - return nil, err - } - - for paginator.HasNext() { - page, err := paginator.NextPage(ctx) - if err != nil { - plugin.Logger(ctx).Error("ListBlob 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 getBlobFilters = map[string]string{ - "blob_sha": "Description.SHA", - "content": "Description.Content", - "encoding": "Description.Encoding", - "node_id": "Description.NodeID", - "repository_full_name": "Description.RepoFullName", - "size": "Description.Size", - "url": "Description.URL", -} - -func GetBlob(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { - plugin.Logger(ctx).Trace("GetBlob") - 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 - } - integrationID, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyIntegrationID) - 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.NewBlobPaginator(essdk.BuildFilter(ctx, d.QueryContext, getBlobFilters, integrationID, 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: Blob ============================= - // ========================== START: Branch ============================= type Branch struct { @@ -1610,18 +1395,17 @@ func (p CommitPaginator) NextPage(ctx context.Context) ([]Commit, error) { } var listCommitFilters = map[string]string{ - "additional_details": "Description.AdditionalDetails", - "author": "Description.Author", - "changes": "Description.Changes", - "comment_count": "Description.CommentCount", - "date": "Description.Date", - "files": "Description.Files", - "html_url": "Description.HTMLURL", - "id": "Description.ID", - "is_verified": "Description.IsVerified", - "message": "Description.Message", - "pull_requests": "Description.PullRequests", - "target": "Description.Target", + "author": "Description.Author", + "comments_url": "Description.CommentsURL", + "commit_detail": "Description.CommitDetail", + "commiter": "Description.Committer", + "files": "Description.Files", + "html_url": "Description.HTMLURL", + "node_id": "Description.NodeID", + "parents": "Description.Parents", + "sha": "Description.SHA", + "stats": "Description.Stats", + "url": "Description.URL", } func ListCommit(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { @@ -1685,18 +1469,17 @@ func ListCommit(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) } var getCommitFilters = map[string]string{ - "additional_details": "Description.AdditionalDetails", - "author": "Description.Author", - "changes": "Description.Changes", - "comment_count": "Description.CommentCount", - "date": "Description.Date", - "files": "Description.Files", - "html_url": "Description.HTMLURL", - "id": "Description.ID", - "is_verified": "Description.IsVerified", - "message": "Description.Message", - "pull_requests": "Description.PullRequests", - "target": "Description.Target", + "author": "Description.Author", + "comments_url": "Description.CommentsURL", + "commit_detail": "Description.CommitDetail", + "commiter": "Description.Committer", + "files": "Description.Files", + "html_url": "Description.HTMLURL", + "node_id": "Description.NodeID", + "parents": "Description.Parents", + "sha": "Description.SHA", + "stats": "Description.Stats", + "url": "Description.URL", } func GetCommit(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { @@ -3047,221 +2830,6 @@ func GetOrgAlertDependabot(ctx context.Context, d *plugin.QueryData, _ *plugin.H // ========================== END: OrgAlertDependabot ============================= -// ========================== START: OrgExternalIdentity ============================= - -type OrgExternalIdentity struct { - ResourceID string `json:"resource_id"` - PlatformID string `json:"platform_id"` - Description github.OrgExternalIdentityDescription `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 OrgExternalIdentityHit struct { - ID string `json:"_id"` - Score float64 `json:"_score"` - Index string `json:"_index"` - Type string `json:"_type"` - Version int64 `json:"_version,omitempty"` - Source OrgExternalIdentity `json:"_source"` - Sort []interface{} `json:"sort"` -} - -type OrgExternalIdentityHits struct { - Total essdk.SearchTotal `json:"total"` - Hits []OrgExternalIdentityHit `json:"hits"` -} - -type OrgExternalIdentitySearchResponse struct { - PitID string `json:"pit_id"` - Hits OrgExternalIdentityHits `json:"hits"` -} - -type OrgExternalIdentityPaginator struct { - paginator *essdk.BaseESPaginator -} - -func (k Client) NewOrgExternalIdentityPaginator(filters []essdk.BoolFilter, limit *int64) (OrgExternalIdentityPaginator, error) { - paginator, err := essdk.NewPaginator(k.ES(), "github_organization_external_identity", filters, limit) - if err != nil { - return OrgExternalIdentityPaginator{}, err - } - - p := OrgExternalIdentityPaginator{ - paginator: paginator, - } - - return p, nil -} - -func (p OrgExternalIdentityPaginator) HasNext() bool { - return !p.paginator.Done() -} - -func (p OrgExternalIdentityPaginator) Close(ctx context.Context) error { - return p.paginator.Deallocate(ctx) -} - -func (p OrgExternalIdentityPaginator) NextPage(ctx context.Context) ([]OrgExternalIdentity, error) { - var response OrgExternalIdentitySearchResponse - err := p.paginator.Search(ctx, &response) - if err != nil { - return nil, err - } - - var values []OrgExternalIdentity - 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 listOrgExternalIdentityFilters = map[string]string{ - "guid": "Description.Guid", - "organization": "Description.Organization", - "organization_invitation": "Description.OrganizationInvitation", - "saml_identity": "Description.SamlIdentity", - "scim_identity": "Description.ScimIdentity", - "user_detail": "Description.User", - "user_login": "Description.User.Login", -} - -func ListOrgExternalIdentity(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { - plugin.Logger(ctx).Trace("ListOrgExternalIdentity") - runtime.GC() - - // create service - cfg := essdk.GetConfig(d.Connection) - ke, err := essdk.NewClientCached(cfg, d.ConnectionCache, ctx) - if err != nil { - plugin.Logger(ctx).Error("ListOrgExternalIdentity NewClientCached", "error", err) - return nil, err - } - k := Client{Client: ke} - - sc, err := steampipesdk.NewSelfClientCached(ctx, d.ConnectionCache) - if err != nil { - plugin.Logger(ctx).Error("ListOrgExternalIdentity NewSelfClientCached", "error", err) - return nil, err - } - integrationID, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyIntegrationID) - if err != nil { - plugin.Logger(ctx).Error("ListOrgExternalIdentity GetConfigTableValueOrNil for OpenGovernanceConfigKeyIntegrationID", "error", err) - return nil, err - } - encodedResourceCollectionFilters, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyResourceCollectionFilters) - if err != nil { - plugin.Logger(ctx).Error("ListOrgExternalIdentity GetConfigTableValueOrNil for OpenGovernanceConfigKeyResourceCollectionFilters", "error", err) - return nil, err - } - clientType, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyClientType) - if err != nil { - plugin.Logger(ctx).Error("ListOrgExternalIdentity GetConfigTableValueOrNil for OpenGovernanceConfigKeyClientType", "error", err) - return nil, err - } - - paginator, err := k.NewOrgExternalIdentityPaginator(essdk.BuildFilter(ctx, d.QueryContext, listOrgExternalIdentityFilters, integrationID, encodedResourceCollectionFilters, clientType), d.QueryContext.Limit) - if err != nil { - plugin.Logger(ctx).Error("ListOrgExternalIdentity NewOrgExternalIdentityPaginator", "error", err) - return nil, err - } - - for paginator.HasNext() { - page, err := paginator.NextPage(ctx) - if err != nil { - plugin.Logger(ctx).Error("ListOrgExternalIdentity 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 getOrgExternalIdentityFilters = map[string]string{ - "guid": "Description.Guid", - "organization": "Description.Organization", - "organization_invitation": "Description.OrganizationInvitation", - "saml_identity": "Description.SamlIdentity", - "scim_identity": "Description.ScimIdentity", - "user_detail": "Description.User", - "user_login": "Description.User.Login", -} - -func GetOrgExternalIdentity(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { - plugin.Logger(ctx).Trace("GetOrgExternalIdentity") - 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 - } - integrationID, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyIntegrationID) - 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.NewOrgExternalIdentityPaginator(essdk.BuildFilter(ctx, d.QueryContext, getOrgExternalIdentityFilters, integrationID, 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: OrgExternalIdentity ============================= - // ========================== START: OrgMembers ============================= type OrgMembers struct { @@ -6010,72 +5578,72 @@ func GetTag(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (in // ========================== END: Tag ============================= -// ========================== START: TeamMembers ============================= +// ========================== START: Team ============================= -type TeamMembers struct { - ResourceID string `json:"resource_id"` - PlatformID string `json:"platform_id"` - Description github.TeamMembersDescription `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 Team struct { + ResourceID string `json:"resource_id"` + PlatformID string `json:"platform_id"` + Description github.TeamDescription `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 TeamMembersHit struct { +type TeamHit struct { ID string `json:"_id"` Score float64 `json:"_score"` Index string `json:"_index"` Type string `json:"_type"` Version int64 `json:"_version,omitempty"` - Source TeamMembers `json:"_source"` + Source Team `json:"_source"` Sort []interface{} `json:"sort"` } -type TeamMembersHits struct { +type TeamHits struct { Total essdk.SearchTotal `json:"total"` - Hits []TeamMembersHit `json:"hits"` + Hits []TeamHit `json:"hits"` } -type TeamMembersSearchResponse struct { - PitID string `json:"pit_id"` - Hits TeamMembersHits `json:"hits"` +type TeamSearchResponse struct { + PitID string `json:"pit_id"` + Hits TeamHits `json:"hits"` } -type TeamMembersPaginator struct { +type TeamPaginator struct { paginator *essdk.BaseESPaginator } -func (k Client) NewTeamMembersPaginator(filters []essdk.BoolFilter, limit *int64) (TeamMembersPaginator, error) { - paginator, err := essdk.NewPaginator(k.ES(), "github_team_member", filters, limit) +func (k Client) NewTeamPaginator(filters []essdk.BoolFilter, limit *int64) (TeamPaginator, error) { + paginator, err := essdk.NewPaginator(k.ES(), "github_organization_team", filters, limit) if err != nil { - return TeamMembersPaginator{}, err + return TeamPaginator{}, err } - p := TeamMembersPaginator{ + p := TeamPaginator{ paginator: paginator, } return p, nil } -func (p TeamMembersPaginator) HasNext() bool { +func (p TeamPaginator) HasNext() bool { return !p.paginator.Done() } -func (p TeamMembersPaginator) Close(ctx context.Context) error { +func (p TeamPaginator) Close(ctx context.Context) error { return p.paginator.Deallocate(ctx) } -func (p TeamMembersPaginator) NextPage(ctx context.Context) ([]TeamMembers, error) { - var response TeamMembersSearchResponse +func (p TeamPaginator) NextPage(ctx context.Context) ([]Team, error) { + var response TeamSearchResponse err := p.paginator.Search(ctx, &response) if err != nil { return nil, err } - var values []TeamMembers + var values []Team for _, hit := range response.Hits.Hits { values = append(values, hit.Source) } @@ -6090,56 +5658,80 @@ func (p TeamMembersPaginator) NextPage(ctx context.Context) ([]TeamMembers, erro return values, nil } -var listTeamMembersFilters = map[string]string{ - "organization": "Description.Organization", - "role": "Description.Role", - "slug": "Description.Slug", -} - -func ListTeamMembers(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { - plugin.Logger(ctx).Trace("ListTeamMembers") +var listTeamFilters = map[string]string{ + "ancestors_total_count": "Description.AncestorsTotalCount", + "avatar_url": "Description.AvatarURL", + "can_administer": "Description.CanAdminister", + "can_subscribe": "Description.CanSubscribe", + "child_teams_total_count": "Description.ChildTeamsTotalCount", + "combined_slug": "Description.CombinedSlug", + "description": "Description.Description", + "discussions_total_count": "Description.DiscussionsTotalCount", + "discussions_url": "Description.DiscussionsURL", + "edit_team_url": "Description.EditTeamURL", + "id": "Description.ID", + "invitations_total_count": "Description.InvitationsTotalCount", + "members_total_count": "Description.MembersTotalCount", + "members_url": "Description.MembersURL", + "name": "Description.Name", + "new_team_url": "Description.NewTeamURL", + "node_id": "Description.NodeID", + "organization": "Description.Organization", + "parent_team": "Description.ParentTeam", + "privacy": "Description.Privacy", + "projects_v2_total_count": "Description.ProjectsV2TotalCount", + "repositories_total_count": "Description.RepositoriesTotalCount", + "repositories_url": "Description.RepositoriesURL", + "slug": "Description.Slug", + "subscription": "Description.Subscription", + "teams_url": "Description.TeamsURL", + "url": "Description.URL", +} + +func ListTeam(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("ListTeam") runtime.GC() // create service cfg := essdk.GetConfig(d.Connection) ke, err := essdk.NewClientCached(cfg, d.ConnectionCache, ctx) if err != nil { - plugin.Logger(ctx).Error("ListTeamMembers NewClientCached", "error", err) + plugin.Logger(ctx).Error("ListTeam NewClientCached", "error", err) return nil, err } k := Client{Client: ke} sc, err := steampipesdk.NewSelfClientCached(ctx, d.ConnectionCache) if err != nil { - plugin.Logger(ctx).Error("ListTeamMembers NewSelfClientCached", "error", err) + plugin.Logger(ctx).Error("ListTeam NewSelfClientCached", "error", err) return nil, err } integrationID, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyIntegrationID) if err != nil { - plugin.Logger(ctx).Error("ListTeamMembers GetConfigTableValueOrNil for OpenGovernanceConfigKeyIntegrationID", "error", err) + plugin.Logger(ctx).Error("ListTeam GetConfigTableValueOrNil for OpenGovernanceConfigKeyIntegrationID", "error", err) return nil, err } encodedResourceCollectionFilters, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyResourceCollectionFilters) if err != nil { - plugin.Logger(ctx).Error("ListTeamMembers GetConfigTableValueOrNil for OpenGovernanceConfigKeyResourceCollectionFilters", "error", err) + plugin.Logger(ctx).Error("ListTeam GetConfigTableValueOrNil for OpenGovernanceConfigKeyResourceCollectionFilters", "error", err) return nil, err } clientType, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyClientType) if err != nil { - plugin.Logger(ctx).Error("ListTeamMembers GetConfigTableValueOrNil for OpenGovernanceConfigKeyClientType", "error", err) + plugin.Logger(ctx).Error("ListTeam GetConfigTableValueOrNil for OpenGovernanceConfigKeyClientType", "error", err) return nil, err } - paginator, err := k.NewTeamMembersPaginator(essdk.BuildFilter(ctx, d.QueryContext, listTeamMembersFilters, integrationID, encodedResourceCollectionFilters, clientType), d.QueryContext.Limit) + paginator, err := k.NewTeamPaginator(essdk.BuildFilter(ctx, d.QueryContext, listTeamFilters, integrationID, encodedResourceCollectionFilters, clientType), d.QueryContext.Limit) if err != nil { - plugin.Logger(ctx).Error("ListTeamMembers NewTeamMembersPaginator", "error", err) + plugin.Logger(ctx).Error("ListTeam NewTeamPaginator", "error", err) return nil, err } for paginator.HasNext() { page, err := paginator.NextPage(ctx) if err != nil { - plugin.Logger(ctx).Error("ListTeamMembers paginator.NextPage", "error", err) + plugin.Logger(ctx).Error("ListTeam paginator.NextPage", "error", err) return nil, err } @@ -6156,14 +5748,38 @@ func ListTeamMembers(ctx context.Context, d *plugin.QueryData, _ *plugin.Hydrate return nil, nil } -var getTeamMembersFilters = map[string]string{ - "organization": "Description.Organization", - "role": "Description.Role", - "slug": "Description.Slug", -} - -func GetTeamMembers(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { - plugin.Logger(ctx).Trace("GetTeamMembers") +var getTeamFilters = map[string]string{ + "ancestors_total_count": "Description.AncestorsTotalCount", + "avatar_url": "Description.AvatarURL", + "can_administer": "Description.CanAdminister", + "can_subscribe": "Description.CanSubscribe", + "child_teams_total_count": "Description.ChildTeamsTotalCount", + "combined_slug": "Description.CombinedSlug", + "description": "Description.Description", + "discussions_total_count": "Description.DiscussionsTotalCount", + "discussions_url": "Description.DiscussionsURL", + "edit_team_url": "Description.EditTeamURL", + "id": "Description.ID", + "invitations_total_count": "Description.InvitationsTotalCount", + "members_total_count": "Description.MembersTotalCount", + "members_url": "Description.MembersURL", + "name": "Description.Name", + "new_team_url": "Description.NewTeamURL", + "node_id": "Description.NodeID", + "organization": "Description.Organization", + "parent_team": "Description.ParentTeam", + "privacy": "Description.Privacy", + "projects_v2_total_count": "Description.ProjectsV2TotalCount", + "repositories_total_count": "Description.RepositoriesTotalCount", + "repositories_url": "Description.RepositoriesURL", + "slug": "Description.Slug", + "subscription": "Description.Subscription", + "teams_url": "Description.TeamsURL", + "url": "Description.URL", +} + +func GetTeam(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("GetTeam") runtime.GC() // create service cfg := essdk.GetConfig(d.Connection) @@ -6191,7 +5807,7 @@ func GetTeamMembers(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateD } limit := int64(1) - paginator, err := k.NewTeamMembersPaginator(essdk.BuildFilter(ctx, d.QueryContext, getTeamMembersFilters, integrationID, encodedResourceCollectionFilters, clientType), &limit) + paginator, err := k.NewTeamPaginator(essdk.BuildFilter(ctx, d.QueryContext, getTeamFilters, integrationID, encodedResourceCollectionFilters, clientType), &limit) if err != nil { return nil, err } @@ -6215,74 +5831,74 @@ func GetTeamMembers(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateD return nil, nil } -// ========================== END: TeamMembers ============================= +// ========================== END: Team ============================= -// ========================== START: Tree ============================= +// ========================== START: TeamMembers ============================= -type Tree struct { - ResourceID string `json:"resource_id"` - PlatformID string `json:"platform_id"` - Description github.TreeDescription `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 TeamMembers struct { + ResourceID string `json:"resource_id"` + PlatformID string `json:"platform_id"` + Description github.TeamMembersDescription `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 TreeHit struct { +type TeamMembersHit struct { ID string `json:"_id"` Score float64 `json:"_score"` Index string `json:"_index"` Type string `json:"_type"` Version int64 `json:"_version,omitempty"` - Source Tree `json:"_source"` + Source TeamMembers `json:"_source"` Sort []interface{} `json:"sort"` } -type TreeHits struct { +type TeamMembersHits struct { Total essdk.SearchTotal `json:"total"` - Hits []TreeHit `json:"hits"` + Hits []TeamMembersHit `json:"hits"` } -type TreeSearchResponse struct { - PitID string `json:"pit_id"` - Hits TreeHits `json:"hits"` +type TeamMembersSearchResponse struct { + PitID string `json:"pit_id"` + Hits TeamMembersHits `json:"hits"` } -type TreePaginator struct { +type TeamMembersPaginator struct { paginator *essdk.BaseESPaginator } -func (k Client) NewTreePaginator(filters []essdk.BoolFilter, limit *int64) (TreePaginator, error) { - paginator, err := essdk.NewPaginator(k.ES(), "github_tree", filters, limit) +func (k Client) NewTeamMembersPaginator(filters []essdk.BoolFilter, limit *int64) (TeamMembersPaginator, error) { + paginator, err := essdk.NewPaginator(k.ES(), "github_team_member", filters, limit) if err != nil { - return TreePaginator{}, err + return TeamMembersPaginator{}, err } - p := TreePaginator{ + p := TeamMembersPaginator{ paginator: paginator, } return p, nil } -func (p TreePaginator) HasNext() bool { +func (p TeamMembersPaginator) HasNext() bool { return !p.paginator.Done() } -func (p TreePaginator) Close(ctx context.Context) error { +func (p TeamMembersPaginator) Close(ctx context.Context) error { return p.paginator.Deallocate(ctx) } -func (p TreePaginator) NextPage(ctx context.Context) ([]Tree, error) { - var response TreeSearchResponse +func (p TeamMembersPaginator) NextPage(ctx context.Context) ([]TeamMembers, error) { + var response TeamMembersSearchResponse err := p.paginator.Search(ctx, &response) if err != nil { return nil, err } - var values []Tree + var values []TeamMembers for _, hit := range response.Hits.Hits { values = append(values, hit.Source) } @@ -6297,63 +5913,56 @@ func (p TreePaginator) NextPage(ctx context.Context) ([]Tree, error) { return values, nil } -var listTreeFilters = map[string]string{ - "mode": "Description.Mode", - "path": "Description.Path", - "recursive": "Description.Recursive", - "repository_full_name": "Description.RepositoryFullName", - "sha": "Description.SHA", - "size": "Description.Size", - "tree_sha": "Description.TreeSHA", - "truncated": "Description.Truncated", - "type": "Description.Type", - "url": "Description.URL", +var listTeamMembersFilters = map[string]string{ + "organization": "Description.Organization", + "role": "Description.Role", + "slug": "Description.Slug", } -func ListTree(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { - plugin.Logger(ctx).Trace("ListTree") +func ListTeamMembers(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("ListTeamMembers") runtime.GC() // create service cfg := essdk.GetConfig(d.Connection) ke, err := essdk.NewClientCached(cfg, d.ConnectionCache, ctx) if err != nil { - plugin.Logger(ctx).Error("ListTree NewClientCached", "error", err) + plugin.Logger(ctx).Error("ListTeamMembers NewClientCached", "error", err) return nil, err } k := Client{Client: ke} sc, err := steampipesdk.NewSelfClientCached(ctx, d.ConnectionCache) if err != nil { - plugin.Logger(ctx).Error("ListTree NewSelfClientCached", "error", err) + plugin.Logger(ctx).Error("ListTeamMembers NewSelfClientCached", "error", err) return nil, err } integrationID, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyIntegrationID) if err != nil { - plugin.Logger(ctx).Error("ListTree GetConfigTableValueOrNil for OpenGovernanceConfigKeyIntegrationID", "error", err) + plugin.Logger(ctx).Error("ListTeamMembers GetConfigTableValueOrNil for OpenGovernanceConfigKeyIntegrationID", "error", err) return nil, err } encodedResourceCollectionFilters, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyResourceCollectionFilters) if err != nil { - plugin.Logger(ctx).Error("ListTree GetConfigTableValueOrNil for OpenGovernanceConfigKeyResourceCollectionFilters", "error", err) + plugin.Logger(ctx).Error("ListTeamMembers GetConfigTableValueOrNil for OpenGovernanceConfigKeyResourceCollectionFilters", "error", err) return nil, err } clientType, err := sc.GetConfigTableValueOrNil(ctx, steampipesdk.OpenGovernanceConfigKeyClientType) if err != nil { - plugin.Logger(ctx).Error("ListTree GetConfigTableValueOrNil for OpenGovernanceConfigKeyClientType", "error", err) + plugin.Logger(ctx).Error("ListTeamMembers GetConfigTableValueOrNil for OpenGovernanceConfigKeyClientType", "error", err) return nil, err } - paginator, err := k.NewTreePaginator(essdk.BuildFilter(ctx, d.QueryContext, listTreeFilters, integrationID, encodedResourceCollectionFilters, clientType), d.QueryContext.Limit) + paginator, err := k.NewTeamMembersPaginator(essdk.BuildFilter(ctx, d.QueryContext, listTeamMembersFilters, integrationID, encodedResourceCollectionFilters, clientType), d.QueryContext.Limit) if err != nil { - plugin.Logger(ctx).Error("ListTree NewTreePaginator", "error", err) + plugin.Logger(ctx).Error("ListTeamMembers NewTeamMembersPaginator", "error", err) return nil, err } for paginator.HasNext() { page, err := paginator.NextPage(ctx) if err != nil { - plugin.Logger(ctx).Error("ListTree paginator.NextPage", "error", err) + plugin.Logger(ctx).Error("ListTeamMembers paginator.NextPage", "error", err) return nil, err } @@ -6370,21 +5979,14 @@ func ListTree(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) ( return nil, nil } -var getTreeFilters = map[string]string{ - "mode": "Description.Mode", - "path": "Description.Path", - "recursive": "Description.Recursive", - "repository_full_name": "Description.RepositoryFullName", - "sha": "Description.SHA", - "size": "Description.Size", - "tree_sha": "Description.TreeSHA", - "truncated": "Description.Truncated", - "type": "Description.Type", - "url": "Description.URL", +var getTeamMembersFilters = map[string]string{ + "organization": "Description.Organization", + "role": "Description.Role", + "slug": "Description.Slug", } -func GetTree(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { - plugin.Logger(ctx).Trace("GetTree") +func GetTeamMembers(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("GetTeamMembers") runtime.GC() // create service cfg := essdk.GetConfig(d.Connection) @@ -6412,7 +6014,7 @@ func GetTree(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (i } limit := int64(1) - paginator, err := k.NewTreePaginator(essdk.BuildFilter(ctx, d.QueryContext, getTreeFilters, integrationID, encodedResourceCollectionFilters, clientType), &limit) + paginator, err := k.NewTeamMembersPaginator(essdk.BuildFilter(ctx, d.QueryContext, getTeamMembersFilters, integrationID, encodedResourceCollectionFilters, clientType), &limit) if err != nil { return nil, err } @@ -6436,7 +6038,7 @@ func GetTree(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (i return nil, nil } -// ========================== END: Tree ============================= +// ========================== END: TeamMembers ============================= // ========================== START: User ============================= diff --git a/provider/describer/blob.go b/provider/describer/blob.go.txt similarity index 100% rename from provider/describer/blob.go rename to provider/describer/blob.go.txt diff --git a/provider/describer/commit.go b/provider/describer/commit.go index 2ae08d6b..7b99efaf 100644 --- a/provider/describer/commit.go +++ b/provider/describer/commit.go @@ -8,6 +8,7 @@ import ( "log" "os" "strconv" + "strings" "sync" "github.com/opengovern/og-describer-github/pkg/sdk/models" @@ -21,7 +22,11 @@ import ( // Otherwise, commits are collected and returned as a slice. func ListCommits(ctx context.Context, githubClient GitHubClient, organizationName string, stream *models.StreamSender) ([]models.Resource, error) { // Retrieve repositories while excluding archived and disabled ones - repos, err := GetRepositoryListWithOptions(ctx, githubClient, organizationName, nil, true, true) + //repos, err := GetRepositoryListWithOptions(ctx, githubClient, organizationName, nil, true, true) + //if err != nil { + // return nil, err + //} + repos, err := getRepositories(ctx, githubClient.RestClient, organizationName) if err != nil { return nil, err } @@ -31,7 +36,7 @@ func ListCommits(ctx context.Context, githubClient GitHubClient, organizationNam var values []models.Resource for _, r := range repos { // r.Name should correspond to the repository name - repoValues, err := GetRepositoryCommits(ctx, sdk, stream, organizationName, r.Name) + repoValues, err := GetRepositoryCommits(ctx, sdk, stream, organizationName, r.GetName()) if err != nil { return nil, err } @@ -47,10 +52,18 @@ func GetRepositoryCommits(ctx context.Context, sdk *resilientbridge.ResilientBri maxCommits := 10 commits, err := fetchCommitList(sdk, owner, repo, maxCommits) if err != nil { + if strings.Contains(err.Error(), "client error: 409") { + return []models.Resource{}, nil + } return nil, fmt.Errorf("error fetching commits list for %s/%s: %w", owner, repo, err) } - // Determine concurrency level from env or default to 5 + if len(commits) == 0 { + log.Printf("No commits found for %s/%s (possibly empty default branch).", owner, repo) + return nil, nil + } + + // Determine concurrency level from env or default to 3 concurrency := 3 if cStr := os.Getenv("CONCURRENCY"); cStr != "" { if cVal, err := strconv.Atoi(cStr); err == nil && cVal > 0 { @@ -82,10 +95,9 @@ func GetRepositoryCommits(ctx context.Context, sdk *resilientbridge.ResilientBri log.Printf("Error unmarshaling JSON for commit %s: %v", j.sha, err) continue } - value := models.Resource{ - ID: commit.ID, - Name: commit.ID, + ID: commit.SHA, + Name: commit.SHA, Description: JSONAllFieldsMarshaller{ Value: commit, }, @@ -106,22 +118,16 @@ func GetRepositoryCommits(ctx context.Context, sdk *resilientbridge.ResilientBri wg.Wait() - if stream != nil { - for _, res := range results { - if res.ID == "" { - continue - } - if err := (*stream)(res); err != nil { - return nil, err - } - } - return nil, nil - } - var finalResults []models.Resource for _, res := range results { if res.ID != "" { - finalResults = append(finalResults, res) + if stream != nil { + if err := (*stream)(res); err != nil { + return nil, err + } + } else { + finalResults = append(finalResults, res) + } } } return finalResults, nil diff --git a/provider/describer/organization_external_identity.go b/provider/describer/organization_external_identity.go.txt similarity index 100% rename from provider/describer/organization_external_identity.go rename to provider/describer/organization_external_identity.go.txt diff --git a/provider/describer/team.go b/provider/describer/organization_team.go similarity index 96% rename from provider/describer/team.go rename to provider/describer/organization_team.go index 8835b61f..2dbec16a 100644 --- a/provider/describer/team.go +++ b/provider/describer/organization_team.go @@ -9,7 +9,7 @@ import ( "strconv" ) -func GetTeamList(ctx context.Context, githubClient GitHubClient, organizationName string, stream *models.StreamSender) ([]models.Resource, error) { +func GetOrganizationTeamList(ctx context.Context, githubClient GitHubClient, organizationName string, stream *models.StreamSender) ([]models.Resource, error) { client := githubClient.GraphQLClient var query struct { RateLimit steampipemodels.RateLimit diff --git a/provider/describer/repository.go b/provider/describer/repository.go index dd822db1..15e11cc9 100644 --- a/provider/describer/repository.go +++ b/provider/describer/repository.go @@ -15,20 +15,22 @@ import ( "github.com/opengovern/resilient-bridge/adapters" ) -// MAX_REPO as requested -const MAX_REPO = 250 +// MAX_REPOS_TO_LIST is how many repositories to fetch at most when listing. +const MAX_REPOS_TO_LIST = 250 -// GetRepositoryList returns a list of all active (non-archived, non-disabled) repos in the organization. -// By default, no excludes are applied, so this returns only active repositories. -func GetRepositoryList(ctx context.Context, githubClient GitHubClient, organizationName string, stream *models.StreamSender) ([]models.Resource, error) { - // Call the helper with default options (no excludes) +// GetRepositoryList calls GetRepositoryListWithOptions with default excludes (false, false). +func GetRepositoryList( + ctx context.Context, + githubClient GitHubClient, + organizationName string, + stream *models.StreamSender, +) ([]models.Resource, error) { return GetRepositoryListWithOptions(ctx, githubClient, organizationName, stream, false, false) } -// GetRepositoryListWithOptions returns a list of all active repos in the organization with options to exclude archived or disabled. -// GetRepositoryListWithOptions fetches repositories for a given organization directly from the GitHub API using resilientbridge. -// It paginates through the results up to MAX_REPO and does not rely on helper functions. -// It does minimal processing: it only extracts 'id' and 'name' fields and stores the entire repo JSON as 'Description'. +// GetRepositoryListWithOptions enumerates org repositories, but *instead of streaming each raw JSON*, +// it calls GetRepository(...) for each repo, so that *only the final detail* from GetRepository is +// streamed and returned. func GetRepositoryListWithOptions( ctx context.Context, githubClient GitHubClient, @@ -45,11 +47,11 @@ func GetRepositoryListWithOptions( BaseBackoff: 0, }) - var allResources []models.Resource + var allFinalResources []models.Resource perPage := 100 page := 1 - for len(allResources) < MAX_REPO { + for len(allFinalResources) < MAX_REPOS_TO_LIST { endpoint := fmt.Sprintf("/orgs/%s/repos?per_page=%d&page=%d", organizationName, perPage, page) req := &resilientbridge.NormalizedRequest{ Method: "GET", @@ -61,24 +63,21 @@ func GetRepositoryListWithOptions( if err != nil { return nil, fmt.Errorf("error fetching repos: %w", err) } - if resp.StatusCode != 200 { return nil, fmt.Errorf("HTTP error %d: %s", resp.StatusCode, string(resp.Data)) } - // Decode into a slice of generic maps to extract 'id', 'name', etc. + // Decode into a slice of generic maps. We'll only parse name, archived, disabled, etc. var repos []map[string]interface{} if err := json.Unmarshal(resp.Data, &repos); err != nil { return nil, fmt.Errorf("error decoding repos list: %w", err) } - if len(repos) == 0 { - // no more repos break } for _, r := range repos { - // Apply filters + // Filter archived, disabled if requested if excludeArchived { if archived, ok := r["archived"].(bool); ok && archived { continue @@ -90,56 +89,60 @@ func GetRepositoryListWithOptions( } } - var idStr string - if idVal, ok := r["id"]; ok { - idStr = fmt.Sprintf("%v", idVal) + // Grab the repo name from the raw JSON + nameStr, _ := r["name"].(string) + if nameStr == "" { + continue } - var nameStr string - if nameVal, ok := r["name"].(string); ok { - nameStr = nameVal + // Now call GetRepository to get the *final* detail + // resourceID can be empty or you can use the raw "id" from r if you like. + var resourceID string + if idVal, ok := r["id"]; ok { + resourceID = fmt.Sprintf("%v", idVal) } - - // Marshal the entire repo object back into JSON for Description - rawData, err := json.Marshal(r) + finalResource, err := GetRepository( + ctx, + githubClient, + organizationName, + nameStr, + resourceID, // pass along or just "" + stream, // same stream pointer + ) if err != nil { - return nil, fmt.Errorf("error marshalling repo data: %w", err) + log.Printf("Error fetching details for %s/%s: %v", organizationName, nameStr, err) + continue } - resource := models.Resource{ - ID: idStr, - Name: nameStr, - Description: JSONAllFieldsMarshaller{ - Value: rawData, - }, - } - - allResources = append(allResources, resource) - if len(allResources) >= MAX_REPO { - break + // Append the final resource from GetRepository into our big slice + if finalResource != nil { + allFinalResources = append(allFinalResources, *finalResource) + if len(allFinalResources) >= MAX_REPOS_TO_LIST { + break + } } } if len(repos) < perPage { - // no more pages + // No more pages break } - page++ } - return allResources, nil + return allFinalResources, nil } -// GetRepository returns details for a given repo +// GetRepository fetches a single repo, transforms it, fetches languages, enriches metrics, returns a single Resource. func GetRepository( ctx context.Context, githubClient GitHubClient, organizationName string, repositoryName string, - resourceID string, + resourceID string, // optional stream *models.StreamSender, ) (*models.Resource, error) { + sdk := resilientbridge.NewResilientBridge() sdk.RegisterProvider("github", adapters.NewGitHubAdapter(githubClient.Token), &resilientbridge.ProviderConfig{ UseProviderLimits: true, @@ -147,260 +150,57 @@ func GetRepository( BaseBackoff: 0, }) - repoDetail, err := _fetchRepoDetails(sdk, organizationName, repositoryName) + // 1) Fetch RepoDetail + repoDetail, err := util_fetchRepoDetails(sdk, organizationName, repositoryName) if err != nil { - return nil, fmt.Errorf("error fetching repository details for %s/%s: %w", organizationName, repositoryName, err) + return nil, fmt.Errorf("error fetching repository details for %s/%s: %w", + organizationName, repositoryName, err) } - finalDetail := _transformToFinalRepoDetail(repoDetail) + // 2) Transform -> RepositoryDescription + finalDetail := util_transformToFinalRepoDetail(repoDetail) - langs, err := _fetchLanguages(sdk, organizationName, repositoryName) - if err == nil { - finalDetail.Languages = langs + // 3) Fetch /languages => map[string]int + langs, err := util_fetchLanguages(sdk, organizationName, repositoryName) + if err == nil && len(langs) > 0 { + finalDetail.LanguageBreakdown = langs } - err = _enrichRepoMetrics(sdk, organizationName, repositoryName, finalDetail) - if err != nil { - log.Printf("Error enriching repo metrics for %s/%s: %v", organizationName, repositoryName, err) + // 4) Enrich with metrics + if err := util_enrichRepoMetrics(sdk, organizationName, repositoryName, finalDetail); err != nil { + log.Printf("Error enriching repo metrics for %s/%s: %v", + organizationName, repositoryName, err) } + // 5) Build final Resource + // If resourceID is empty, use the finalDetail's ID + if resourceID == "" { + resourceID = strconv.Itoa(finalDetail.GitHubRepoID) + } value := models.Resource{ - ID: strconv.Itoa(finalDetail.GitHubRepoID), + ID: resourceID, Name: finalDetail.Name, Description: JSONAllFieldsMarshaller{ Value: finalDetail, }, } - fmt.Println(value) - // If a stream is provided, send the resource through the stream + // Stream if provided if stream != nil { if err := (*stream)(value); err != nil { - return nil, err + return nil, fmt.Errorf("streaming resource failed: %w", err) } } return &value, nil } -// Utility/helper functions (prefixed with underscore) - -// _fetchLanguages fetches repository languages. -func _fetchLanguages(sdk *resilientbridge.ResilientBridge, owner, repo string) (map[string]int, error) { - req := &resilientbridge.NormalizedRequest{ - Method: "GET", - Endpoint: fmt.Sprintf("/repos/%s/%s/languages", owner, repo), - Headers: map[string]string{"Accept": "application/vnd.github+json"}, - } - - resp, err := sdk.Request("github", req) - if err != nil { - return nil, fmt.Errorf("error fetching languages: %w", err) - } - - if resp.StatusCode >= 400 { - return nil, fmt.Errorf("HTTP error %d: %s", resp.StatusCode, string(resp.Data)) - } - - var langs map[string]int - if err := json.Unmarshal(resp.Data, &langs); err != nil { - return nil, fmt.Errorf("error decoding languages: %w", err) - } - return langs, nil -} - -// _enrichRepoMetrics enriches repo metrics such as commits, issues, branches, etc. -func _enrichRepoMetrics(sdk *resilientbridge.ResilientBridge, owner, repoName string, finalDetail *model.RepositoryDescription) error { - var dbObj map[string]string - if finalDetail.DefaultBranchRef != nil { - if err := json.Unmarshal(finalDetail.DefaultBranchRef, &dbObj); err != nil { - return err - } - } - defaultBranch := dbObj["name"] - if defaultBranch == "" { - defaultBranch = "main" - } - - commitsCount, err := _countCommits(sdk, owner, repoName, defaultBranch) - if err != nil { - return fmt.Errorf("counting commits: %w", err) - } - finalDetail.Metrics.Commits = commitsCount - - issuesCount, err := _countIssues(sdk, owner, repoName) - if err != nil { - return fmt.Errorf("counting issues: %w", err) - } - finalDetail.Metrics.Issues = issuesCount - - branchesCount, err := _countBranches(sdk, owner, repoName) - if err != nil { - return fmt.Errorf("counting branches: %w", err) - } - finalDetail.Metrics.Branches = branchesCount - - prCount, err := _countPullRequests(sdk, owner, repoName) - if err != nil { - return fmt.Errorf("counting PRs: %w", err) - } - finalDetail.Metrics.PullRequests = prCount - - releasesCount, err := _countReleases(sdk, owner, repoName) - if err != nil { - return fmt.Errorf("counting releases: %w", err) - } - finalDetail.Metrics.Releases = releasesCount - - tagsCount, err := _countTags(sdk, owner, repoName) - if err != nil { - return fmt.Errorf("counting tags: %w", err) - } - finalDetail.Metrics.Tags = tagsCount - - return nil -} - -func _countTags(sdk *resilientbridge.ResilientBridge, owner, repoName string) (int, error) { - endpoint := fmt.Sprintf("/repos/%s/%s/tags?per_page=1", owner, repoName) - return _countItemsFromEndpoint(sdk, endpoint) -} - -func _countCommits(sdk *resilientbridge.ResilientBridge, owner, repoName, defaultBranch string) (int, error) { - endpoint := fmt.Sprintf("/repos/%s/%s/commits?sha=%s&per_page=1", owner, repoName, defaultBranch) - return _countItemsFromEndpoint(sdk, endpoint) -} - -func _countIssues(sdk *resilientbridge.ResilientBridge, owner, repoName string) (int, error) { - endpoint := fmt.Sprintf("/repos/%s/%s/issues?state=all&per_page=1", owner, repoName) - return _countItemsFromEndpoint(sdk, endpoint) -} - -func _countBranches(sdk *resilientbridge.ResilientBridge, owner, repoName string) (int, error) { - endpoint := fmt.Sprintf("/repos/%s/%s/branches?per_page=1", owner, repoName) - return _countItemsFromEndpoint(sdk, endpoint) -} - -func _countPullRequests(sdk *resilientbridge.ResilientBridge, owner, repoName string) (int, error) { - endpoint := fmt.Sprintf("/repos/%s/%s/pulls?state=all&per_page=1", owner, repoName) - return _countItemsFromEndpoint(sdk, endpoint) -} - -func _countReleases(sdk *resilientbridge.ResilientBridge, owner, repoName string) (int, error) { - endpoint := fmt.Sprintf("/repos/%s/%s/releases?per_page=1", owner, repoName) - return _countItemsFromEndpoint(sdk, endpoint) -} - -func _countItemsFromEndpoint(sdk *resilientbridge.ResilientBridge, endpoint string) (int, error) { - req := &resilientbridge.NormalizedRequest{ - Method: "GET", - Endpoint: endpoint, - Headers: map[string]string{"Accept": "application/vnd.github+json"}, - } - - resp, err := sdk.Request("github", req) - if err != nil { - return 0, fmt.Errorf("error fetching data: %w", err) - } - - if resp.StatusCode == 409 { - return 0, nil - } - - if resp.StatusCode >= 400 { - return 0, fmt.Errorf("HTTP error %d: %s", resp.StatusCode, string(resp.Data)) - } - - var linkHeader string - for k, v := range resp.Headers { - if strings.ToLower(k) == "link" { - linkHeader = v - break - } - } - - if linkHeader == "" { - if len(resp.Data) > 2 { - var items []interface{} - if err := json.Unmarshal(resp.Data, &items); err != nil { - return 1, nil - } - return len(items), nil - } - return 0, nil - } - - lastPage, err := _parseLastPage(linkHeader) - if err != nil { - return 0, fmt.Errorf("could not parse last page: %w", err) - } - - return lastPage, nil -} - -func _parseLastPage(linkHeader string) (int, error) { - re := regexp.MustCompile(`page=(\d+)>; rel="last"`) - matches := re.FindStringSubmatch(linkHeader) - if len(matches) < 2 { - return 1, nil - } - var lastPage int - _, err := fmt.Sscanf(matches[1], "%d", &lastPage) - if err != nil { - return 0, err - } - return lastPage, nil -} - -func _fetchOrgRepos(sdk *resilientbridge.ResilientBridge, org string, maxResults int) ([]model.MinimalRepoInfo, error) { - var allRepos []model.MinimalRepoInfo - perPage := 100 - page := 1 - - for len(allRepos) < maxResults { - remaining := maxResults - len(allRepos) - if remaining < perPage { - perPage = remaining - } - - endpoint := fmt.Sprintf("/orgs/%s/repos?per_page=%d&page=%d", org, perPage, page) - listReq := &resilientbridge.NormalizedRequest{ - Method: "GET", - Endpoint: endpoint, - Headers: map[string]string{"Accept": "application/vnd.github+json"}, - } +// ----------------------------------------------------------------------------- +// Utility / helper functions +// (unchanged from your existing code except for naming and minor comments) +// ----------------------------------------------------------------------------- - listResp, err := sdk.Request("github", listReq) - if err != nil { - return nil, fmt.Errorf("error fetching repos: %w", err) - } - - if listResp.StatusCode >= 400 { - return nil, fmt.Errorf("HTTP error %d: %s", listResp.StatusCode, string(listResp.Data)) - } - - var repos []model.MinimalRepoInfo - if err := json.Unmarshal(listResp.Data, &repos); err != nil { - return nil, fmt.Errorf("error decoding repos list: %w", err) - } - - if len(repos) == 0 { - break - } - - allRepos = append(allRepos, repos...) - if len(allRepos) >= maxResults { - break - } - page++ - } - if len(allRepos) > maxResults { - allRepos = allRepos[:maxResults] - } - return allRepos, nil -} - -func _fetchRepoDetails(sdk *resilientbridge.ResilientBridge, owner, repo string) (*model.RepoDetail, error) { +func util_fetchRepoDetails(sdk *resilientbridge.ResilientBridge, owner, repo string) (*model.RepoDetail, error) { req := &resilientbridge.NormalizedRequest{ Method: "GET", Endpoint: fmt.Sprintf("/repos/%s/%s", owner, repo), @@ -421,14 +221,14 @@ func _fetchRepoDetails(sdk *resilientbridge.ResilientBridge, owner, repo string) return &detail, nil } -func _transformToFinalRepoDetail(detail *model.RepoDetail) *model.RepositoryDescription { +func util_transformToFinalRepoDetail(detail *model.RepoDetail) *model.RepositoryDescription { var parent *model.RepositoryDescription if detail.Parent != nil { - parent = _transformToFinalRepoDetail(detail.Parent) + parent = util_transformToFinalRepoDetail(detail.Parent) } var source *model.RepositoryDescription if detail.Source != nil { - source = _transformToFinalRepoDetail(detail.Source) + source = util_transformToFinalRepoDetail(detail.Source) } var finalOwner *model.Owner @@ -463,8 +263,9 @@ func _transformToFinalRepoDetail(detail *model.RepoDetail) *model.RepositoryDesc var licenseJSON json.RawMessage if detail.License != nil { - lj, _ := json.Marshal(detail.License) - licenseJSON = lj + if data, err := json.Marshal(detail.License); err == nil { + licenseJSON = data + } } finalDetail := &model.RepositoryDescription{ @@ -490,7 +291,13 @@ func _transformToFinalRepoDetail(detail *model.RepoDetail) *model.RepositoryDesc Organization: finalOrg, Parent: parent, Source: source, - Languages: nil, + + // Single primary language from /repos + PrimaryLanguage: detail.PrimaryLanguage, + + // We'll fill in LanguageBreakdown after calling /languages + LanguageBreakdown: nil, + RepositorySettings: model.RepositorySettings{ HasDiscussionsEnabled: detail.HasDiscussions, HasIssuesEnabled: detail.HasIssues, @@ -541,38 +348,196 @@ func _transformToFinalRepoDetail(detail *model.RepoDetail) *model.RepositoryDesc OpenIssues: detail.OpenIssuesCount, }, } + return finalDetail } -func _getRepositoriesDetail(ctx context.Context, sdk *resilientbridge.ResilientBridge, organizationName, repo string, stream *models.StreamSender) *models.Resource { - repoDetail, err := _fetchRepoDetails(sdk, organizationName, repo) +func util_fetchLanguages( + sdk *resilientbridge.ResilientBridge, + owner, repo string, +) (map[string]int, error) { + + req := &resilientbridge.NormalizedRequest{ + Method: "GET", + Endpoint: fmt.Sprintf("/repos/%s/%s/languages", owner, repo), + Headers: map[string]string{"Accept": "application/vnd.github+json"}, + } + resp, err := sdk.Request("github", req) if err != nil { - log.Printf("Error fetching details for %s/%s: %v", organizationName, repo, err) - return nil + return nil, fmt.Errorf("error fetching languages: %w", err) + } + if resp.StatusCode >= 400 { + return nil, fmt.Errorf("HTTP error %d: %s", resp.StatusCode, string(resp.Data)) + } + + var langs map[string]int + if err := json.Unmarshal(resp.Data, &langs); err != nil { + return nil, fmt.Errorf("error decoding languages: %w", err) + } + return langs, nil +} + +func util_enrichRepoMetrics( + sdk *resilientbridge.ResilientBridge, + owner, repoName string, + finalDetail *model.RepositoryDescription, +) error { + + var dbObj map[string]string + if finalDetail.DefaultBranchRef != nil { + if err := json.Unmarshal(finalDetail.DefaultBranchRef, &dbObj); err != nil { + return err + } + } + defaultBranch := dbObj["name"] + if defaultBranch == "" { + defaultBranch = "main" } - finalDetail := _transformToFinalRepoDetail(repoDetail) - langs, err := _fetchLanguages(sdk, organizationName, repo) - if err == nil { - finalDetail.Languages = langs + commitsCount, err := util_countCommits(sdk, owner, repoName, defaultBranch) + if err != nil { + return fmt.Errorf("counting commits: %w", err) } + finalDetail.Metrics.Commits = commitsCount - err = _enrichRepoMetrics(sdk, organizationName, repo, finalDetail) + issuesCount, err := util_countIssues(sdk, owner, repoName) if err != nil { - log.Printf("Error enriching repo metrics for %s/%s: %v", organizationName, repo, err) + return fmt.Errorf("counting issues: %w", err) } + finalDetail.Metrics.Issues = issuesCount - value := models.Resource{ - ID: strconv.Itoa(finalDetail.GitHubRepoID), - Name: finalDetail.Name, - Description: JSONAllFieldsMarshaller{ - Value: finalDetail, - }, + branchesCount, err := util_countBranches(sdk, owner, repoName) + if err != nil { + return fmt.Errorf("counting branches: %w", err) } - if stream != nil { - if err := (*stream)(value); err != nil { - return nil + finalDetail.Metrics.Branches = branchesCount + + prCount, err := util_countPullRequests(sdk, owner, repoName) + if err != nil { + return fmt.Errorf("counting PRs: %w", err) + } + finalDetail.Metrics.PullRequests = prCount + + releasesCount, err := util_countReleases(sdk, owner, repoName) + if err != nil { + return fmt.Errorf("counting releases: %w", err) + } + finalDetail.Metrics.Releases = releasesCount + + tagsCount, err := util_countTags(sdk, owner, repoName) + if err != nil { + return fmt.Errorf("counting tags: %w", err) + } + finalDetail.Metrics.Tags = tagsCount + + return nil +} + +func util_countTags( + sdk *resilientbridge.ResilientBridge, + owner, repoName string, +) (int, error) { + endpoint := fmt.Sprintf("/repos/%s/%s/tags?per_page=1", owner, repoName) + return util_countItemsFromEndpoint(sdk, endpoint) +} + +func util_countCommits( + sdk *resilientbridge.ResilientBridge, + owner, repoName, defaultBranch string, +) (int, error) { + endpoint := fmt.Sprintf("/repos/%s/%s/commits?sha=%s&per_page=1", owner, repoName, defaultBranch) + return util_countItemsFromEndpoint(sdk, endpoint) +} + +func util_countIssues( + sdk *resilientbridge.ResilientBridge, + owner, repoName string, +) (int, error) { + endpoint := fmt.Sprintf("/repos/%s/%s/issues?state=all&per_page=1", owner, repoName) + return util_countItemsFromEndpoint(sdk, endpoint) +} + +func util_countBranches( + sdk *resilientbridge.ResilientBridge, + owner, repoName string, +) (int, error) { + endpoint := fmt.Sprintf("/repos/%s/%s/branches?per_page=1", owner, repoName) + return util_countItemsFromEndpoint(sdk, endpoint) +} + +func util_countPullRequests( + sdk *resilientbridge.ResilientBridge, + owner, repoName string, +) (int, error) { + endpoint := fmt.Sprintf("/repos/%s/%s/pulls?state=all&per_page=1", owner, repoName) + return util_countItemsFromEndpoint(sdk, endpoint) +} + +func util_countReleases( + sdk *resilientbridge.ResilientBridge, + owner, repoName string, +) (int, error) { + endpoint := fmt.Sprintf("/repos/%s/%s/releases?per_page=1", owner, repoName) + return util_countItemsFromEndpoint(sdk, endpoint) +} + +func util_countItemsFromEndpoint( + sdk *resilientbridge.ResilientBridge, + endpoint string, +) (int, error) { + + req := &resilientbridge.NormalizedRequest{ + Method: "GET", + Endpoint: endpoint, + Headers: map[string]string{"Accept": "application/vnd.github+json"}, + } + resp, err := sdk.Request("github", req) + if err != nil { + return 0, fmt.Errorf("error fetching data: %w", err) + } + if resp.StatusCode == 409 { + return 0, nil + } + if resp.StatusCode >= 400 { + return 0, fmt.Errorf("HTTP error %d: %s", resp.StatusCode, string(resp.Data)) + } + + var linkHeader string + for k, v := range resp.Headers { + if strings.ToLower(k) == "link" { + linkHeader = v + break + } + } + + if linkHeader == "" { + // If there's no Link header, see if the response is an array + if len(resp.Data) > 2 { + var items []interface{} + if err := json.Unmarshal(resp.Data, &items); err != nil { + return 1, nil + } + return len(items), nil } + return 0, nil + } + + lastPage, err := util_parseLastPage(linkHeader) + if err != nil { + return 0, fmt.Errorf("could not parse last page: %w", err) + } + return lastPage, nil +} + +func util_parseLastPage(linkHeader string) (int, error) { + re := regexp.MustCompile(`page=(\d+)>; rel="last"`) + matches := re.FindStringSubmatch(linkHeader) + if len(matches) < 2 { + return 1, nil } - return &value + var lastPage int + if _, err := fmt.Sscanf(matches[1], "%d", &lastPage); err != nil { + return 0, err + } + return lastPage, nil } diff --git a/provider/describer/tree.go b/provider/describer/tree.go.txt similarity index 100% rename from provider/describer/tree.go rename to provider/describer/tree.go.txt diff --git a/provider/describer/utils.go b/provider/describer/utils.go index 1f06c2ed..4ed17d1d 100644 --- a/provider/describer/utils.go +++ b/provider/describer/utils.go @@ -1360,7 +1360,12 @@ func getRepositories(ctx context.Context, client *github.Client, owner string) ( return nil, err } - repositories = append(repositories, repos...) + for _, r := range repos { + if r.GetArchived() || r.GetDisabled() { + continue + } + repositories = append(repositories, r) + } if resp.NextPage == 0 { break } diff --git a/provider/describer/workflow.go b/provider/describer/workflow.go index c87d45bd..9196ff7e 100644 --- a/provider/describer/workflow.go +++ b/provider/describer/workflow.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/opengovern/og-describer-github/pkg/sdk/models" "github.com/opengovern/og-describer-github/provider/model" - "log" "strconv" "strings" @@ -19,14 +18,13 @@ func GetAllWorkflows(ctx context.Context, githubClient GitHubClient, organizatio repositories, err := getRepositories(ctx, client, organizationName) if err != nil { - return nil, nil + return nil, err } var values []models.Resource for _, repo := range repositories { if repo == nil { continue } - log.Println(repo.GetName()) repoValues, err := GetRepositoryWorkflows(ctx, githubClient, stream, organizationName, repo.GetName()) if err != nil { return nil, err diff --git a/provider/model/model.go b/provider/model/model.go index ab14da2c..ac287354 100755 --- a/provider/model/model.go +++ b/provider/model/model.go @@ -197,72 +197,139 @@ type BranchProtectionDescription struct { BypassPullRequestAllowanceUsers []BranchUser } -type Parents []struct { - SHA string `json:"sha"` -} +//type Parents []struct { +// SHA string `json:"sha"` +//} + +//type VerificationDetails struct { +// Reason string `json:"reason"` +// Signature *string `json:"signature"` +// VerifiedAt *string `json:"verified_at"` +//} + +//type AdditionalDetails struct { +// NodeID string `json:"node_id"` +// Parents Parents `json:"parents"` +// Tree Tree `json:"tree"` +// VerificationDetails VerificationDetails `json:"verification_details"` +//} + +//type UserMinimalInfo struct { +// Name string `json:"name"` +// Email string `json:"email"` +// Date string `json:"date"` +//} + +//type Changes struct { +// Additions int `json:"additions"` +// Deletions int `json:"deletions"` +// Total int `json:"total"` +//} type Tree struct { SHA string `json:"sha"` + URL string `json:"url"` } -type VerificationDetails struct { +type File struct { + SHA string `json:"sha"` + Filename string `json:"filename"` + Status string `json:"status"` + Additions int `json:"additions"` + Deletions int `json:"deletions"` + Changes int `json:"changes"` + BlobURL string `json:"blob_url"` + RawURL string `json:"raw_url"` + ContentsURL string `json:"contents_url"` + Patch *string `json:"patch"` +} + +type Target struct { + Branch string `json:"branch"` + Organization string `json:"organization"` + Repository string `json:"repository"` +} + +type Verification struct { + Verified bool `json:"verified"` Reason string `json:"reason"` Signature *string `json:"signature"` + Payload *string `json:"payload"` VerifiedAt *string `json:"verified_at"` } -type AdditionalDetails struct { - NodeID string `json:"node_id"` - Parents Parents `json:"parents"` - Tree Tree `json:"tree"` - VerificationDetails VerificationDetails `json:"verification_details"` -} - -type Author struct { - Email string `json:"email"` +type User struct { + Login string `json:"login"` + ID int `json:"id"` + NodeID string `json:"node_id"` + AvatarURL string `json:"avatar_url"` + GravatarID string `json:"gravatar_id"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + FollowersURL string `json:"followers_url"` + FollowingURL string `json:"following_url"` + GistsURL string `json:"gists_url"` + StarredURL string `json:"starred_url"` + SubscriptionsURL string `json:"subscriptions_url"` + OrganizationsURL string `json:"organizations_url"` + ReposURL string `json:"repos_url"` + EventsURL string `json:"events_url"` + ReceivedEventsURL string `json:"received_events_url"` + Type string `json:"type"` + UserViewType string `json:"user_view_type"` + SiteAdmin bool `json:"site_admin"` +} + +type CommitDetail struct { + //Author UserMinimalInfo `json:"author"` + //Committer UserMinimalInfo `json:"committer"` + Message string `json:"message"` + Tree Tree `json:"tree"` + //URL string `json:"url"` + CommentCount int `json:"comment_count"` + Verification Verification `json:"verification"` +} + +type Parent struct { + SHA string `json:"sha"` + URL string `json:"url"` HTMLURL string `json:"html_url"` - ID int `json:"id"` - Login string `json:"login"` - Name string `json:"name"` - NodeID string `json:"node_id"` - Type string `json:"type"` } -type Changes struct { +type Stats struct { + Total int `json:"total"` Additions int `json:"additions"` Deletions int `json:"deletions"` - Total int `json:"total"` -} - -type File struct { - Additions int `json:"additions"` - Changes int `json:"changes"` - Deletions int `json:"deletions"` - Filename string `json:"filename"` - SHA string `json:"sha"` - Status string `json:"status"` -} - -type Target struct { - Branch string `json:"branch"` - Organization string `json:"organization"` - Repository string `json:"repository"` } type CommitDescription struct { - AdditionalDetails AdditionalDetails `json:"additional_details"` - Author Author `json:"author"` - Changes Changes `json:"changes"` - CommentCount int `json:"comment_count"` - Date string `json:"date"` - Files []File `json:"files"` - HTMLURL string `json:"html_url"` - ID string `json:"id"` - IsVerified bool `json:"is_verified"` - Message string `json:"message"` - PullRequests []int `json:"pull_requests"` - Target Target `json:"target"` -} + SHA string `json:"sha"` + NodeID string `json:"node_id"` + CommitDetail CommitDetail `json:"commit"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + CommentsURL string `json:"comments_url"` + Author User `json:"author"` + Committer User `json:"committer"` + Parents []Parent `json:"parents"` + Stats Stats `json:"stats"` + Files []File `json:"files"` +} + +//type CommitDescription struct { +// AdditionalDetails AdditionalDetails `json:"additional_details"` +// Author Author `json:"author"` +// Changes Changes `json:"changes"` +// CommentCount int `json:"comment_count"` +// Date string `json:"date"` +// Files []File `json:"files"` +// HTMLURL string `json:"html_url"` +// ID string `json:"id"` +// IsVerified bool `json:"is_verified"` +// Message string `json:"message"` +// PullRequests []int `json:"pull_requests"` +// Target Target `json:"target"` +//} type IssueDescription struct { RepositoryFullName string @@ -502,27 +569,32 @@ type StatusObj struct { } type RepoDetail struct { - ID int `json:"id"` - NodeID string `json:"node_id"` - Name string `json:"name"` - FullName string `json:"full_name"` - Private bool `json:"private"` - Owner *Owner `json:"owner"` - HTMLURL string `json:"html_url"` - Description *string `json:"description"` - Fork bool `json:"fork"` - CreatedAt string `json:"created_at"` - UpdatedAt string `json:"updated_at"` - PushedAt string `json:"pushed_at"` - GitURL string `json:"git_url"` - SSHURL string `json:"ssh_url"` - CloneURL string `json:"clone_url"` - SVNURL string `json:"svn_url"` - Homepage *string `json:"homepage"` - Size int `json:"size"` - StargazersCount int `json:"stargazers_count"` - WatchersCount int `json:"watchers_count"` - Languages *string `json:"languages"` // original string language field + ID int `json:"id"` + NodeID string `json:"node_id"` + Name string `json:"name"` + FullName string `json:"full_name"` + Private bool `json:"private"` + Owner *Owner `json:"owner"` + HTMLURL string `json:"html_url"` + Description *string `json:"description"` + Fork bool `json:"fork"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + PushedAt string `json:"pushed_at"` + GitURL string `json:"git_url"` + SSHURL string `json:"ssh_url"` + CloneURL string `json:"clone_url"` + SVNURL string `json:"svn_url"` + Homepage *string `json:"homepage"` + Size int `json:"size"` + StargazersCount int `json:"stargazers_count"` + WatchersCount int `json:"watchers_count"` + + // 1) The single “primary” language returned by the main /repos/:owner/:repo call + PrimaryLanguage *string `json:"language"` + // If you want to store the breakdown from /languages in the same struct, you can do: + LanguageBreakdown map[string]int `json:"-"` + HasIssues bool `json:"has_issues"` HasProjects bool `json:"has_projects"` HasDownloads bool `json:"has_downloads"` @@ -651,6 +723,118 @@ type Metrics struct { Releases int `json:"releases"` } +//type RepositoryResponse struct { +// ID float64 `json:"id"` +// NodeID string `json:"node_id"` +// Name string `json:"name"` +// NameWithOwner string `json:"name_with_owner"` +// Description *string `json:"description"` +// Private bool `json:"private"` +// HTMLURL string `json:"html_url"` +// Fork bool `json:"fork"` +// URL string `json:"url"` +// CloneURL string `json:"clone_url"` +// GitURL string `json:"git_url"` +// SSHURL string `json:"ssh_url"` +// Homepage *string `json:"homepage"` +// Language string `json:"language"` +// ForksCount int `json:"forks_count"` +// StargazersCount int `json:"stargazers_count"` +// WatchersCount int `json:"watchers_count"` +// Size int `json:"size"` +// DefaultBranch string `json:"default_branch"` +// OpenIssuesCount int `json:"open_issues_count"` +// Topics []string `json:"topics"` +// HasIssues bool `json:"has_issues"` +// HasProjects bool `json:"has_projects"` +// HasWiki bool `json:"has_wiki"` +// HasPages bool `json:"has_pages"` +// HasDownloads bool `json:"has_downloads"` +// HasDiscussions bool `json:"has_discussions"` +// Archived bool `json:"archived"` +// Disabled bool `json:"disabled"` +// Visibility string `json:"visibility"` +// PushedAt string `json:"pushed_at"` +// CreatedAt string `json:"created_at"` +// UpdatedAt string `json:"updated_at"` +// AllowForking bool `json:"allow_forking"` +// WebCommitSignoffRequired bool `json:"web_commit_signoff_required"` +// ContentsURL string `json:"contents_url"` +// PullsURL string `json:"pulls_url"` +// CommitsURL string `json:"commits_url"` +// CompareURL string `json:"compare_url"` +// DownloadsURL string `json:"downloads_url"` +// ArchiveURL string `json:"archive_url"` +// AssigneesURL string `json:"assignees_url"` +// BlobsURL string `json:"blobs_url"` +// BranchesURL string `json:"branches_url"` +// CollaboratorsURL string `json:"collaborators_url"` +// CommentsURL string `json:"comments_url"` +// ContributorsURL string `json:"contributors_url"` +// DeploymentsURL string `json:"deployments_url"` +// EventsURL string `json:"events_url"` +// ForksURL string `json:"forks_url"` +// GitCommitsURL string `json:"git_commits_url"` +// GitRefsURL string `json:"git_refs_url"` +// GitTagsURL string `json:"git_tags_url"` +// HooksURL string `json:"hooks_url"` +// IssueCommentURL string `json:"issue_comment_url"` +// IssueEventsURL string `json:"issue_events_url"` +// IssuesURL string `json:"issues_url"` +// KeysURL string `json:"keys_url"` +// LabelsURL string `json:"labels_url"` +// LanguagesURL string `json:"languages_url"` +// MergesURL string `json:"merges_url"` +// MilestonesURL string `json:"milestones_url"` +// NotificationsURL string `json:"notifications_url"` +// ReleasesURL string `json:"releases_url"` +// StargazersURL string `json:"stargazers_url"` +// StatusesURL string `json:"statuses_url"` +// SubscribersURL string `json:"subscribers_url"` +// SubscriptionURL string `json:"subscription_url"` +// TagsURL string `json:"tags_url"` +// TeamsURL string `json:"teams_url"` +// TreesURL string `json:"trees_url"` +// Watchers int `json:"watchers"` +// IsTemplate bool `json:"is_template"` +// SecurityAndAnalysis map[string]map[string]string `json:"security_and_analysis"` +// Permissions map[string]bool `json:"permissions"` +// Owner RepoOwner `json:"owner"` +//} +// +//type RepoOwner struct { +// Login string `json:"login"` +// ID int64 `json:"id"` +// NodeID string `json:"node_id"` +// AvatarURL string `json:"avatar_url"` +// GravatarID string `json:"gravatar_id"` +// URL string `json:"url"` +// HTMLURL string `json:"html_url"` +// FollowersURL string `json:"followers_url"` +// FollowingURL string `json:"following_url"` +// GistsURL string `json:"gists_url"` +// StarredURL string `json:"starred_url"` +// SubscriptionsURL string `json:"subscriptions_url"` +// OrganizationsURL string `json:"organizations_url"` +// ReposURL string `json:"repos_url"` +// EventsURL string `json:"events_url"` +// ReceivedEventsURL string `json:"received_events_url"` +// Type string `json:"type"` +// SiteAdmin bool `json:"site_admin"` +//} +// +//type LicenseInfo struct { +// Key string `json:"key"` +// Name string `json:"name"` +// SPDXID string `json:"spdx_id"` +// URL string `json:"url"` +// NodeID string `json:"node_id"` +//} +// +//type DefaultBranchRef struct { +// Name string `json:"name"` +//} + type RepositoryDescription struct { GitHubRepoID int `json:"id"` NodeID string `json:"node_id"` @@ -674,7 +858,8 @@ type RepositoryDescription struct { Organization *Organization `json:"organization"` Parent *RepositoryDescription `json:"parent"` Source *RepositoryDescription `json:"source"` - Languages map[string]int `json:"language"` + PrimaryLanguage *string `json:"primary_language,omitempty"` + LanguageBreakdown map[string]int `json:"language_breakdown,omitempty"` RepositorySettings RepositorySettings `json:"repo_settings"` SecuritySettings SecuritySettings `json:"security_settings"` RepoURLs RepoURLs `json:"repo_urls"` @@ -690,88 +875,6 @@ type MinimalRepoInfo struct { } `json:"owner"` } -//type RepoDescription struct { -// github.Repository -// ID int -// NodeID string -// Name string -// NameWithOwner string -// Description string -// IsArchived bool -// IsEmpty bool -// IsFork bool -// IsSecurityPolicyEnabled bool -// OwnerLogin string -// LicenseInfo steampipemodels.BasicLicense -// Visibility githubv4.RepositoryVisibility -// Topics []string -// DefaultBranchRef steampipemodels.BasicRefWithBranchProtectionRule -// YourPermission githubv4.RepositoryPermission -// CreatedAt steampipemodels.NullableTime -// UpdatedAt steampipemodels.NullableTime -// PushedAt steampipemodels.NullableTime -// AllowUpdateBranch bool -// ArchivedAt steampipemodels.NullableTime -// AutoMergeAllowed bool -// CodeOfConduct steampipemodels.RepositoryCodeOfConduct -// ContactLinks []steampipemodels.RepositoryContactLink -// DeleteBranchOnMerge bool -// DiskUsage int -// ForkCount int -// ForkingAllowed bool -// FundingLinks []steampipemodels.RepositoryFundingLinks -// HasDiscussionsEnabled bool -// HasIssuesEnabled bool -// HasProjectsEnabled bool -// HasVulnerabilityAlertsEnabled bool -// HasWikiEnabled bool -// HomepageURL string -// InteractionAbility steampipemodels.RepositoryInteractionAbility -// IsBlankIssuesEnabled bool -// IsDisabled bool -// IsInOrganization bool -// IsLocked bool -// IsMirror bool -// IsPrivate bool -// IsTemplate bool -// IsUserConfigurationRepository bool -// IssueTemplates []steampipemodels.IssueTemplate -// LockReason githubv4.LockReason -// MergeCommitAllowed bool -// MergeCommitMessage githubv4.MergeCommitMessage -// MergeCommitTitle githubv4.MergeCommitTitle -// MirrorURL string -// OpenGraphImageURL string -// PrimaryLanguage steampipemodels.Language -// ProjectsURL string -// PullRequestTemplates []steampipemodels.PullRequestTemplate -// RebaseMergeAllowed bool -// SecurityPolicyURL string -// SquashMergeAllowed bool -// SquashMergeCommitMessage githubv4.SquashMergeCommitMessage -// SquashMergeCommitTitle githubv4.SquashMergeCommitTitle -// SSHURL string -// StargazerCount int -// URL string -// //UsesCustomOpenGraphImage bool -// //CanAdminister bool -// //CanCreateProjects bool -// //CanSubscribe bool -// //CanUpdateTopics bool -// //HasStarred bool -// PossibleCommitEmails []string -// //Subscription githubv4.SubscriptionState -// WebCommitSignOffRequired bool -// RepositoryTopicsTotalCount int -// OpenIssuesTotalCount int -// WatchersTotalCount int -// Hooks []*github.Hook -// SubscribersCount int -// HasDownloads bool -// HasPages bool -// NetworkCount int -//} - type ReleaseDescription struct { github.RepositoryRelease RepositoryFullName string diff --git a/provider/resource_types.go b/provider/resource_types.go index 0d3a39ec..fd3c3929 100644 --- a/provider/resource_types.go +++ b/provider/resource_types.go @@ -56,18 +56,6 @@ var ResourceTypes = map[string]model.ResourceType{ GetDescriber: nil, }, - "Github/Blob": { - IntegrationType: configs.IntegrationName, - ResourceName: "Github/Blob", - Tags: map[string][]string{ - "category": {"Blob"}, - }, - Labels: map[string]string{}, - Annotations: map[string]string{}, - ListDescriber: DescribeByGithub(describer.GetAllBlobs), - GetDescriber: DescribeSingleByRepo(describer.GetBlob), - }, - "Github/Branch": { IntegrationType: configs.IntegrationName, ResourceName: "Github/Branch", @@ -77,7 +65,7 @@ var ResourceTypes = map[string]model.ResourceType{ Labels: map[string]string{}, Annotations: map[string]string{}, ListDescriber: DescribeByGithub(describer.GetAllBranches), - GetDescriber: DescribeSingleByRepo(describer.GetBlob), + GetDescriber: nil, }, "Github/Branch/Protection": { @@ -164,27 +152,27 @@ var ResourceTypes = map[string]model.ResourceType{ GetDescriber: nil, }, - "Github/Organization/External/Identity": { + "Github/Organization/Member": { IntegrationType: configs.IntegrationName, - ResourceName: "Github/Organization/External/Identity", + ResourceName: "Github/Organization/Member", Tags: map[string][]string{ "category": {"Organization"}, }, Labels: map[string]string{}, Annotations: map[string]string{}, - ListDescriber: DescribeByGithub(describer.GetAllExternalIdentities), + ListDescriber: DescribeByGithub(describer.GetAllMembers), GetDescriber: nil, }, - "Github/Organization/Member": { + "Github/Organization/Team": { IntegrationType: configs.IntegrationName, - ResourceName: "Github/Organization/Member", + ResourceName: "Github/Organization/Team", Tags: map[string][]string{ "category": {"Organization"}, }, Labels: map[string]string{}, Annotations: map[string]string{}, - ListDescriber: DescribeByGithub(describer.GetAllMembers), + ListDescriber: DescribeByGithub(describer.GetOrganizationTeamList), GetDescriber: nil, }, @@ -221,7 +209,7 @@ var ResourceTypes = map[string]model.ResourceType{ Labels: map[string]string{}, Annotations: map[string]string{}, ListDescriber: DescribeByGithub(describer.GetRepositoryList), - GetDescriber: nil, + GetDescriber: DescribeSingleByRepo(describer.GetRepository), }, "Github/Repository/Collaborator": { @@ -332,18 +320,6 @@ var ResourceTypes = map[string]model.ResourceType{ GetDescriber: nil, }, - "Github/Tree": { - IntegrationType: configs.IntegrationName, - ResourceName: "Github/Tree", - Tags: map[string][]string{ - "category": {"tree"}, - }, - Labels: map[string]string{}, - Annotations: map[string]string{}, - ListDescriber: DescribeByGithub(describer.GetAllTrees), - GetDescriber: nil, - }, - "Github/User": { IntegrationType: configs.IntegrationName, ResourceName: "Github/User", diff --git a/provider/resource_types/resource-types.json b/provider/resource_types/resource-types.json index 8cae1a20..cc6db275 100644 --- a/provider/resource_types/resource-types.json +++ b/provider/resource_types/resource-types.json @@ -47,18 +47,6 @@ "SteampipeTable": "github_actions_workflow_run", "Model": "WorkflowRun" }, - { - "ResourceName": "Github/Blob", - "Tags": { - "category": [ - "Blob" - ] - }, - "ListDescriber": "DescribeByGithub(describer.GetAllBlobs)", - "GetDescriber": "DescribeSingleByRepo(describer.GetBlob)", - "SteampipeTable": "github_blob", - "Model": "Blob" - }, { "ResourceName": "Github/Branch", "Tags": { @@ -67,7 +55,7 @@ ] }, "ListDescriber": "DescribeByGithub(describer.GetAllBranches)", - "GetDescriber": "DescribeSingleByRepo(describer.GetBlob)", + "GetDescriber": "", "SteampipeTable": "github_branch", "Model": "Branch" }, @@ -156,28 +144,28 @@ "Model": "OrgAlertDependabot" }, { - "ResourceName": "Github/Organization/External/Identity", + "ResourceName": "Github/Organization/Member", "Tags": { "category": [ "Organization" ] }, - "ListDescriber": "DescribeByGithub(describer.GetAllExternalIdentities)", + "ListDescriber": "DescribeByGithub(describer.GetAllMembers)", "GetDescriber": "", - "SteampipeTable": "github_organization_external_identity", - "Model": "OrgExternalIdentity" + "SteampipeTable": "github_organization_member", + "Model": "OrgMembers" }, { - "ResourceName": "Github/Organization/Member", + "ResourceName": "Github/Organization/Team", "Tags": { "category": [ "Organization" ] }, - "ListDescriber": "DescribeByGithub(describer.GetAllMembers)", + "ListDescriber": "DescribeByGithub(describer.GetOrganizationTeamList)", "GetDescriber": "", - "SteampipeTable": "github_organization_member", - "Model": "OrgMembers" + "SteampipeTable": "github_organization_team", + "Model": "Team" }, { "ResourceName": "Github/PullRequest", @@ -211,7 +199,7 @@ ] }, "ListDescriber": "DescribeByGithub(describer.GetRepositoryList)", - "GetDescriber": "", + "GetDescriber": "DescribeSingleByRepo(describer.GetRepository)", "SteampipeTable": "github_repository", "Model": "Repository" }, @@ -311,7 +299,6 @@ "SteampipeTable": "github_tag", "Model": "Tag" }, - { "ResourceName": "Github/Team/Member", "Tags": { @@ -324,18 +311,6 @@ "SteampipeTable": "github_team_member", "Model": "TeamMembers" }, - { - "ResourceName": "Github/Tree", - "Tags": { - "category": [ - "tree" - ] - }, - "ListDescriber": "DescribeByGithub(describer.GetAllTrees)", - "GetDescriber": "", - "SteampipeTable": "github_tree", - "Model": "Tree" - }, { "ResourceName": "Github/User", "Tags": { diff --git a/steampipe-plugin-github/github/plugin.go b/steampipe-plugin-github/github/plugin.go index af10ecf1..73521a02 100644 --- a/steampipe-plugin-github/github/plugin.go +++ b/steampipe-plugin-github/github/plugin.go @@ -23,25 +23,26 @@ func Plugin(ctx context.Context) *plugin.Plugin { "github_actions_runner": tableGitHubActionsRepositoryRunner(), "github_actions_secret": tableGitHubActionsRepositorySecret(), "github_actions_workflow_run": tableGitHubActionsRepositoryWorkflowRun(), - "github_blob": tableGitHubBlob(), - "github_branch": tableGitHubBranch(), - "github_branch_protection": tableGitHubBranchProtection(), + //"github_blob": tableGitHubBlob(), + "github_branch": tableGitHubBranch(), + "github_branch_protection": tableGitHubBranchProtection(), //"github_code_owner": tableGitHubCodeOwner(), - "github_commit": tableGitHubCommit(), - "github_issue": tableGitHubIssue(), - "github_license": tableGitHubLicense(), - "github_organization": tableGitHubOrganization(), - "github_organization_dependabot_alert": tableGitHubOrganizationDependabotAlert(), - "github_organization_external_identity": tableGitHubOrganizationExternalIdentity(), - "github_organization_member": tableGitHubOrganizationMember(), - "github_organization_collaborator": tableGitHubOrganizationCollaborator(), - "github_pull_request": tableGitHubPullRequest(), - "github_pull_request_review": tableGitHubPullRequestReview(), - "github_rate_limit": tableGitHubRateLimit(), - "github_rate_limit_graphql": tableGitHubRateLimitGraphQL(), - "github_release": tableGitHubRelease(), - "github_repository": tableGitHubRepository(), - "github_repository_collaborator": tableGitHubRepositoryCollaborator(), + "github_commit": tableGitHubCommit(), + "github_issue": tableGitHubIssue(), + "github_license": tableGitHubLicense(), + "github_organization": tableGitHubOrganization(), + "github_organization_dependabot_alert": tableGitHubOrganizationDependabotAlert(), + //"github_organization_external_identity": tableGitHubOrganizationExternalIdentity(), + "github_organization_member": tableGitHubOrganizationMember(), + "github_organization_collaborator": tableGitHubOrganizationCollaborator(), + "github_organization_team": tableGitHubOrganizationTeam(), + "github_pull_request": tableGitHubPullRequest(), + "github_pull_request_review": tableGitHubPullRequestReview(), + //"github_rate_limit": tableGitHubRateLimit(), + //"github_rate_limit_graphql": tableGitHubRateLimitGraphQL(), + "github_release": tableGitHubRelease(), + "github_repository": tableGitHubRepository(), + "github_repository_collaborator": tableGitHubRepositoryCollaborator(), // "github_repository_content": tableGitHubRepositoryContent(), "github_repository_dependabot_alert": tableGitHubRepositoryDependabotAlert(), "github_repository_deployment": tableGitHubRepositoryDeployment(), @@ -50,16 +51,15 @@ func Plugin(ctx context.Context) *plugin.Plugin { "github_repository_sbom": tableGitHubRepositorySbom(), "github_repository_vulnerability_alert": tableGitHubRepositoryVulnerabilityAlert(), "github_tag": tableGitHubTag(), - "github_team": tableGitHubTeam(), "github_team_member": tableGitHubTeamMember(), - "github_tree": tableGitHubTree(), - "github_user": tableGitHubUser(), - "github_workflow": tableGitHubWorkflow(), - "github_container_package": tableGitHubContainerPackage(), - "github_maven_package": tableGitHubMavenPackage(), - "github_npm_package": tableGitHubNPMPackage(), - "github_nuget_package": tableGitHubNugetPackage(), - "github_artifact_dockerfile": tableGitHubArtifactDockerFile(), + //"github_tree": tableGitHubTree(), + "github_user": tableGitHubUser(), + "github_workflow": tableGitHubWorkflow(), + "github_container_package": tableGitHubContainerPackage(), + "github_maven_package": tableGitHubMavenPackage(), + "github_npm_package": tableGitHubNPMPackage(), + "github_nuget_package": tableGitHubNugetPackage(), + "github_artifact_dockerfile": tableGitHubArtifactDockerFile(), }, } for key, table := range p.TableMap { diff --git a/steampipe-plugin-github/github/table_github_blob.go b/steampipe-plugin-github/github/table_github_blob.go.txt similarity index 100% rename from steampipe-plugin-github/github/table_github_blob.go rename to steampipe-plugin-github/github/table_github_blob.go.txt diff --git a/steampipe-plugin-github/github/table_github_commit.go b/steampipe-plugin-github/github/table_github_commit.go index 40e935da..9a2935a7 100644 --- a/steampipe-plugin-github/github/table_github_commit.go +++ b/steampipe-plugin-github/github/table_github_commit.go @@ -16,40 +16,34 @@ func tableGitHubCommit() *plugin.Table { Hydrate: opengovernance.ListCommit, }, Get: &plugin.GetConfig{ - KeyColumns: plugin.AllColumns([]string{"id"}), + KeyColumns: plugin.AllColumns([]string{"sha"}), ShouldIgnoreError: isNotFoundError([]string{"404"}), Hydrate: opengovernance.GetCommit, }, Columns: []*plugin.Column{ { - Name: "id", + Name: "sha", Type: proto.ColumnType_STRING, - Transform: transform.FromField("Description.ID"), + Transform: transform.FromField("Description.SHA"), Description: "Unique identifier (SHA) of the commit.", }, { - Name: "message", + Name: "node_id", Type: proto.ColumnType_STRING, - Transform: transform.FromField("Description.Message"), - Description: "Commit message.", + Transform: transform.FromField("Description.NodeID"), + Description: "", }, { - Name: "author", + Name: "commit_detail", Type: proto.ColumnType_JSON, - Transform: transform.FromField("Description.Author"), - Description: "Name of the author of the commit.", + Transform: transform.FromField("Description.CommitDetail"), + Description: "Details of the commit.", }, { - Name: "date", + Name: "url", Type: proto.ColumnType_STRING, - Transform: transform.FromField("Description.Date"), - Description: "Date of the commit.", - }, - { - Name: "comment_count", - Type: proto.ColumnType_INT, - Transform: transform.FromField("Description.CommentCount"), - Description: "Number of comments on the commit.", + Transform: transform.FromField("Description.URL"), + Description: "URL of the commit.", }, { Name: "html_url", @@ -58,40 +52,40 @@ func tableGitHubCommit() *plugin.Table { Description: "URL of the commit on the repository.", }, { - Name: "is_verified", - Type: proto.ColumnType_BOOL, - Transform: transform.FromField("Description.IsVerified"), - Description: "Indicates if the commit is verified.", + Name: "comments_url", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Description.CommentsURL"), + Description: "", }, { - Name: "changes", + Name: "author", Type: proto.ColumnType_JSON, - Transform: transform.FromField("Description.Changes"), - Description: "Details of the changes made in the commit.", + Transform: transform.FromField("Description.Author"), + Description: "Details of the author of the commit", }, { - Name: "files", + Name: "commiter", Type: proto.ColumnType_JSON, - Transform: transform.FromField("Description.Files"), - Description: "List of files changed in the commit.", + Transform: transform.FromField("Description.Committer"), + Description: "Details of the commiter of the commit", }, { - Name: "pull_requests", + Name: "parents", Type: proto.ColumnType_JSON, - Transform: transform.FromField("Description.PullRequests"), - Description: "List of associated pull request IDs.", + Transform: transform.FromField("Description.Parents"), + Description: "Parent commits of the commit", }, { - Name: "target", + Name: "stats", Type: proto.ColumnType_JSON, - Transform: transform.FromField("Description.Target"), - Description: "Target details of the commit (e.g., branch, organization, repository).", + Transform: transform.FromField("Description.Stats"), + Description: "Stats of the commit", }, { - Name: "additional_details", + Name: "files", Type: proto.ColumnType_JSON, - Transform: transform.FromField("Description.AdditionalDetails"), - Description: "Additional details about the commit.", + Transform: transform.FromField("Description.Files"), + Description: "List of files changed in the commit.", }, }, } diff --git a/steampipe-plugin-github/github/table_github_organization_external_identity.go b/steampipe-plugin-github/github/table_github_organization_external_identity.go.txt similarity index 100% rename from steampipe-plugin-github/github/table_github_organization_external_identity.go rename to steampipe-plugin-github/github/table_github_organization_external_identity.go.txt diff --git a/steampipe-plugin-github/github/table_github_organization_team.go b/steampipe-plugin-github/github/table_github_organization_team.go index c2745b43..866f68b6 100644 --- a/steampipe-plugin-github/github/table_github_organization_team.go +++ b/steampipe-plugin-github/github/table_github_organization_team.go @@ -72,9 +72,9 @@ func gitHubTeamColumns() []*plugin.Column { } } -func tableGitHubTeam() *plugin.Table { +func tableGitHubOrganizationTeam() *plugin.Table { return &plugin.Table{ - Name: "github_team", + Name: "github_organization_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{ Hydrate: opengovernance.ListTeamMembers, diff --git a/steampipe-plugin-github/github/table_github_rate_limit.go b/steampipe-plugin-github/github/table_github_rate_limit.go.txt similarity index 100% rename from steampipe-plugin-github/github/table_github_rate_limit.go rename to steampipe-plugin-github/github/table_github_rate_limit.go.txt diff --git a/steampipe-plugin-github/github/table_github_rate_limit_graphql.go b/steampipe-plugin-github/github/table_github_rate_limit_graphql.go.txt similarity index 100% rename from steampipe-plugin-github/github/table_github_rate_limit_graphql.go rename to steampipe-plugin-github/github/table_github_rate_limit_graphql.go.txt diff --git a/steampipe-plugin-github/github/table_github_tree.go b/steampipe-plugin-github/github/table_github_tree.go.txt similarity index 100% rename from steampipe-plugin-github/github/table_github_tree.go rename to steampipe-plugin-github/github/table_github_tree.go.txt diff --git a/steampipe/table_index_map.go b/steampipe/table_index_map.go index ac6d2472..03f65375 100644 --- a/steampipe/table_index_map.go +++ b/steampipe/table_index_map.go @@ -9,7 +9,6 @@ var Map = map[string]string{ "Github/Actions/Runner": "github_actions_runner", "Github/Actions/Secret": "github_actions_secret", "Github/Actions/WorkflowRun": "github_actions_workflow_run", - "Github/Blob": "github_blob", "Github/Branch": "github_branch", "Github/Branch/Protection": "github_branch_protection", "Github/Commit": "github_commit", @@ -18,8 +17,8 @@ var Map = map[string]string{ "Github/Organization": "github_organization", "Github/Organization/Collaborator": "github_organization_collaborator", "Github/Organization/Dependabot/Alert": "github_organization_dependabot_alert", - "Github/Organization/External/Identity": "github_organization_external_identity", "Github/Organization/Member": "github_organization_member", + "Github/Organization/Team": "github_organization_team", "Github/PullRequest": "github_pull_request", "Github/Release": "github_release", "Github/Repository": "github_repository", @@ -32,7 +31,6 @@ var Map = map[string]string{ "Github/Repository/VulnerabilityAlert": "github_repository_vulnerability_alert", "Github/Tag": "github_tag", "Github/Team/Member": "github_team_member", - "Github/Tree": "github_tree", "Github/User": "github_user", "Github/Workflow": "github_workflow", "Github/Container/Package": "github_container_package", @@ -47,7 +45,6 @@ var DescriptionMap = map[string]interface{}{ "Github/Actions/Runner": opengovernance.Runner{}, "Github/Actions/Secret": opengovernance.Secret{}, "Github/Actions/WorkflowRun": opengovernance.WorkflowRun{}, - "Github/Blob": opengovernance.Blob{}, "Github/Branch": opengovernance.Branch{}, "Github/Branch/Protection": opengovernance.BranchProtection{}, "Github/Commit": opengovernance.Commit{}, @@ -56,8 +53,8 @@ var DescriptionMap = map[string]interface{}{ "Github/Organization": opengovernance.Organization{}, "Github/Organization/Collaborator": opengovernance.OrgCollaborators{}, "Github/Organization/Dependabot/Alert": opengovernance.OrgAlertDependabot{}, - "Github/Organization/External/Identity": opengovernance.OrgExternalIdentity{}, "Github/Organization/Member": opengovernance.OrgMembers{}, + "Github/Organization/Team": opengovernance.Team{}, "Github/PullRequest": opengovernance.PullRequest{}, "Github/Release": opengovernance.Release{}, "Github/Repository": opengovernance.Repository{}, @@ -70,7 +67,6 @@ var DescriptionMap = map[string]interface{}{ "Github/Repository/VulnerabilityAlert": opengovernance.RepoVulnerabilityAlert{}, "Github/Tag": opengovernance.Tag{}, "Github/Team/Member": opengovernance.TeamMembers{}, - "Github/Tree": opengovernance.Tree{}, "Github/User": opengovernance.User{}, "Github/Workflow": opengovernance.Workflow{}, "Github/Container/Package": opengovernance.ContainerPackage{}, @@ -85,7 +81,6 @@ var ReverseMap = map[string]string{ "github_actions_runner": "Github/Actions/Runner", "github_actions_secret": "Github/Actions/Secret", "github_actions_workflow_run": "Github/Actions/WorkflowRun", - "github_blob": "Github/Blob", "github_branch": "Github/Branch", "github_branch_protection": "Github/Branch/Protection", "github_commit": "Github/Commit", @@ -94,8 +89,8 @@ var ReverseMap = map[string]string{ "github_organization": "Github/Organization", "github_organization_collaborator": "Github/Organization/Collaborator", "github_organization_dependabot_alert": "Github/Organization/Dependabot/Alert", - "github_organization_external_identity": "Github/Organization/External/Identity", "github_organization_member": "Github/Organization/Member", + "github_organization_team": "Github/Organization/Team", "github_pull_request": "Github/PullRequest", "github_release": "Github/Release", "github_repository": "Github/Repository", @@ -108,7 +103,6 @@ var ReverseMap = map[string]string{ "github_repository_vulnerability_alert": "Github/Repository/VulnerabilityAlert", "github_tag": "Github/Tag", "github_team_member": "Github/Team/Member", - "github_tree": "Github/Tree", "github_user": "Github/User", "github_workflow": "Github/Workflow", "github_container_package": "Github/Container/Package",