Skip to content

Commit

Permalink
fix: comment steampipemodels import
Browse files Browse the repository at this point in the history
  • Loading branch information
ArshiaBP committed Nov 15, 2024
1 parent 8a5d3f6 commit 3a36d4f
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 138 deletions.
10 changes: 4 additions & 6 deletions provider/describer/organization_collaborators.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package describer
import (
"context"
"github.com/opengovern/og-describer-github/pkg/sdk/models"
"github.com/shurcooL/githubv4"
steampipemodels "github.com/turbot/steampipe-plugin-github/github/models"
)

type CollaboratorEdge struct {
Permission githubv4.RepositoryPermission `graphql:"permission @include(if:$includeOCPermission)" json:"permission"`
Node steampipemodels.CollaboratorLogin `graphql:"node @include(if:$includeOCNode)" json:"node"`
}
//type CollaboratorEdge struct {
// Permission githubv4.RepositoryPermission `graphql:"permission @include(if:$includeOCPermission)" json:"permission"`
// Node steampipemodels.CollaboratorLogin `graphql:"node @include(if:$includeOCNode)" json:"node"`
//}

func GetAllOrganizationsCollaborators(ctx context.Context, githubClient GitHubClient, stream *models.StreamSender) ([]models.Resource, error) {
client := githubClient.RestClient
Expand Down
11 changes: 5 additions & 6 deletions provider/describer/organization_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package describer
import (
"context"
"github.com/opengovern/og-describer-github/pkg/sdk/models"
steampipemodels "github.com/turbot/steampipe-plugin-github/github/models"
)

type memberWithRole struct {
HasTwoFactorEnabled *bool
Role *string
Node steampipemodels.User
}
//type memberWithRole struct {
// HasTwoFactorEnabled *bool
// Role *string
// Node steampipemodels.User
//}

func GetAllMembers(ctx context.Context, githubClient GitHubClient, stream *models.StreamSender) ([]models.Resource, error) {
client := githubClient.RestClient
Expand Down
10 changes: 4 additions & 6 deletions provider/describer/repository_collaborators.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package describer
import (
"context"
"github.com/opengovern/og-describer-github/pkg/sdk/models"
"github.com/shurcooL/githubv4"
steampipemodels "github.com/turbot/steampipe-plugin-github/github/models"
)

type RepositoryCollaborator struct {
Permission githubv4.RepositoryPermission
Node steampipemodels.BasicUser
}
//type RepositoryCollaborator struct {
// Permission githubv4.RepositoryPermission
// Node steampipemodels.BasicUser
//}

func GetAllRepositoriesCollaborators(ctx context.Context, githubClient GitHubClient, stream *models.StreamSender) ([]models.Resource, error) {
client := githubClient.RestClient
Expand Down
164 changes: 81 additions & 83 deletions provider/describer/repository_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package describer
import (
"context"
"github.com/opengovern/og-describer-github/pkg/sdk/models"
"github.com/shurcooL/githubv4"
steampipemodels "github.com/turbot/steampipe-plugin-github/github/models"
)

func GetAllRepositoriesRuleSets(ctx context.Context, githubClient GitHubClient, stream *models.StreamSender) ([]models.Resource, error) {
Expand Down Expand Up @@ -141,84 +139,84 @@ func GetRepositoryRuleSets(ctx context.Context, githubClient GitHubClient, strea
return nil, nil
}

func getAdditionalRules(ctx context.Context, client *githubv4.Client, databaseID int, owner string, repo string, initialCursor githubv4.String) []steampipemodels.Rule {
var query struct {
RateLimit steampipemodels.RateLimit
Repository struct {
Ruleset struct {
Rules struct {
PageInfo struct {
HasNextPage bool
EndCursor githubv4.String
}
Edges []struct {
Node steampipemodels.Rule
}
} `graphql:"rules(first: $pageSize, after: $cursor)"`
} `graphql:"ruleset(databaseId: $databaseID)"`
} `graphql:"repository(owner: $owner, name: $name)"`
}
variables := map[string]interface{}{
"pageSize": githubv4.Int(100),
"cursor": githubv4.NewString(initialCursor),
"databaseID": githubv4.Int(databaseID),
"owner": githubv4.String(owner),
"name": githubv4.String(repo),
}
var rules []steampipemodels.Rule
for {
err := client.Query(ctx, &query, variables)
if err != nil {
return nil
}
for _, edge := range query.Repository.Ruleset.Rules.Edges {
rules = append(rules, edge.Node)
}
if !query.Repository.Ruleset.Rules.PageInfo.HasNextPage {
break
}
variables["cursor"] = githubv4.NewString(query.Repository.Ruleset.Rules.PageInfo.EndCursor)
}
return rules
}

func getAdditionalBypassActors(ctx context.Context, client *githubv4.Client, owner string, repo string, databaseID int, initialCursor githubv4.String) []steampipemodels.BypassActor {
var query struct {
RateLimit steampipemodels.RateLimit
Repository struct {
Ruleset struct {
BypassActors struct {
PageInfo struct {
HasNextPage bool
EndCursor githubv4.String
}
Edges []struct {
Node steampipemodels.BypassActor
}
} `graphql:"bypassActors(first: $pageSize, after: $cursor)"`
} `graphql:"ruleset(databaseId: $databaseID)"`
} `graphql:"repository(owner: $owner, name: $name)"`
}
variables := map[string]interface{}{
"owner": githubv4.String(owner),
"name": githubv4.String(repo),
"pageSize": githubv4.Int(100),
"cursor": githubv4.NewString(initialCursor),
"databaseID": githubv4.Int(databaseID),
}
var bypassActors []steampipemodels.BypassActor
for {
err := client.Query(ctx, &query, variables)
if err != nil {
return nil
}
for _, edge := range query.Repository.Ruleset.BypassActors.Edges {
bypassActors = append(bypassActors, edge.Node)
}
if !query.Repository.Ruleset.BypassActors.PageInfo.HasNextPage {
break
}
variables["cursor"] = githubv4.NewString(query.Repository.Ruleset.BypassActors.PageInfo.EndCursor)
}
return bypassActors
}
//func getAdditionalRules(ctx context.Context, client *githubv4.Client, databaseID int, owner string, repo string, initialCursor githubv4.String) []steampipemodels.Rule {
// var query struct {
// RateLimit steampipemodels.RateLimit
// Repository struct {
// Ruleset struct {
// Rules struct {
// PageInfo struct {
// HasNextPage bool
// EndCursor githubv4.String
// }
// Edges []struct {
// Node steampipemodels.Rule
// }
// } `graphql:"rules(first: $pageSize, after: $cursor)"`
// } `graphql:"ruleset(databaseId: $databaseID)"`
// } `graphql:"repository(owner: $owner, name: $name)"`
// }
// variables := map[string]interface{}{
// "pageSize": githubv4.Int(100),
// "cursor": githubv4.NewString(initialCursor),
// "databaseID": githubv4.Int(databaseID),
// "owner": githubv4.String(owner),
// "name": githubv4.String(repo),
// }
// var rules []steampipemodels.Rule
// for {
// err := client.Query(ctx, &query, variables)
// if err != nil {
// return nil
// }
// for _, edge := range query.Repository.Ruleset.Rules.Edges {
// rules = append(rules, edge.Node)
// }
// if !query.Repository.Ruleset.Rules.PageInfo.HasNextPage {
// break
// }
// variables["cursor"] = githubv4.NewString(query.Repository.Ruleset.Rules.PageInfo.EndCursor)
// }
// return rules
//}
//
//func getAdditionalBypassActors(ctx context.Context, client *githubv4.Client, owner string, repo string, databaseID int, initialCursor githubv4.String) []steampipemodels.BypassActor {
// var query struct {
// RateLimit steampipemodels.RateLimit
// Repository struct {
// Ruleset struct {
// BypassActors struct {
// PageInfo struct {
// HasNextPage bool
// EndCursor githubv4.String
// }
// Edges []struct {
// Node steampipemodels.BypassActor
// }
// } `graphql:"bypassActors(first: $pageSize, after: $cursor)"`
// } `graphql:"ruleset(databaseId: $databaseID)"`
// } `graphql:"repository(owner: $owner, name: $name)"`
// }
// variables := map[string]interface{}{
// "owner": githubv4.String(owner),
// "name": githubv4.String(repo),
// "pageSize": githubv4.Int(100),
// "cursor": githubv4.NewString(initialCursor),
// "databaseID": githubv4.Int(databaseID),
// }
// var bypassActors []steampipemodels.BypassActor
// for {
// err := client.Query(ctx, &query, variables)
// if err != nil {
// return nil
// }
// for _, edge := range query.Repository.Ruleset.BypassActors.Edges {
// bypassActors = append(bypassActors, edge.Node)
// }
// if !query.Repository.Ruleset.BypassActors.PageInfo.HasNextPage {
// break
// }
// variables["cursor"] = githubv4.NewString(query.Repository.Ruleset.BypassActors.PageInfo.EndCursor)
// }
// return bypassActors
//}
9 changes: 4 additions & 5 deletions provider/describer/stargazer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package describer
import (
"context"
"github.com/opengovern/og-describer-github/pkg/sdk/models"
steampipemodels "github.com/turbot/steampipe-plugin-github/github/models"
)

type Stargazer struct {
StarredAt steampipemodels.NullableTime `graphql:"starredAt @include(if:$includeStargazerStarredAt)" json:"starred_at"`
Node steampipemodels.BasicUser `graphql:"node @include(if:$includeStargazerNode)" json:"node"`
}
//type Stargazer struct {
// StarredAt steampipemodels.NullableTime `graphql:"starredAt @include(if:$includeStargazerStarredAt)" json:"starred_at"`
// Node steampipemodels.BasicUser `graphql:"node @include(if:$includeStargazerNode)" json:"node"`
//}

func GetAllStargazers(ctx context.Context, githubClient GitHubClient, stream *models.StreamSender) ([]models.Resource, error) {
client := githubClient.RestClient
Expand Down
62 changes: 30 additions & 32 deletions provider/describer/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package describer
import (
"context"
"github.com/opengovern/og-describer-github/pkg/sdk/models"
"github.com/shurcooL/githubv4"
steampipemodels "github.com/turbot/steampipe-plugin-github/github/models"
)

func GetTeamList(ctx context.Context, githubClient GitHubClient, stream *models.StreamSender) ([]models.Resource, error) {
Expand Down Expand Up @@ -108,33 +106,33 @@ func GetTeamList(ctx context.Context, githubClient GitHubClient, stream *models.
return nil, nil
}

func getAdditionalTeams(ctx context.Context, client *githubv4.Client, org string, initialCursor githubv4.String) ([]steampipemodels.TeamWithCounts, error) {
var query struct {
RateLimit steampipemodels.RateLimit
Organization struct {
Teams struct {
PageInfo steampipemodels.PageInfo
Nodes []steampipemodels.TeamWithCounts
} `graphql:"teams(first: $pageSize, after: $cursor)"`
} `graphql:"organization(login: $login)"`
}
variables := map[string]interface{}{
"pageSize": githubv4.Int(100),
"cursor": githubv4.NewString(initialCursor),
"login": githubv4.String(org),
}
appendTeamColumnIncludes(&variables, teamCols())
var ts []steampipemodels.TeamWithCounts
for {
err := client.Query(ctx, &query, variables)
if err != nil {
return nil, err
}
ts = append(ts, query.Organization.Teams.Nodes...)
if !query.Organization.Teams.PageInfo.HasNextPage {
break
}
variables["cursor"] = githubv4.NewString(query.Organization.Teams.PageInfo.EndCursor)
}
return ts, nil
}
//func getAdditionalTeams(ctx context.Context, client *githubv4.Client, org string, initialCursor githubv4.String) ([]steampipemodels.TeamWithCounts, error) {
// var query struct {
// RateLimit steampipemodels.RateLimit
// Organization struct {
// Teams struct {
// PageInfo steampipemodels.PageInfo
// Nodes []steampipemodels.TeamWithCounts
// } `graphql:"teams(first: $pageSize, after: $cursor)"`
// } `graphql:"organization(login: $login)"`
// }
// variables := map[string]interface{}{
// "pageSize": githubv4.Int(100),
// "cursor": githubv4.NewString(initialCursor),
// "login": githubv4.String(org),
// }
// appendTeamColumnIncludes(&variables, teamCols())
// var ts []steampipemodels.TeamWithCounts
// for {
// err := client.Query(ctx, &query, variables)
// if err != nil {
// return nil, err
// }
// ts = append(ts, query.Organization.Teams.Nodes...)
// if !query.Organization.Teams.PageInfo.HasNextPage {
// break
// }
// variables["cursor"] = githubv4.NewString(query.Organization.Teams.PageInfo.EndCursor)
// }
// return ts, nil
//}

0 comments on commit 3a36d4f

Please sign in to comment.