Skip to content

Commit

Permalink
Add new fields to GH repos + handle null bools
Browse files Browse the repository at this point in the history
Add new fields + handle a few merge options that are bools with null
values if not set

Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 committed May 5, 2024
1 parent 4f44756 commit 351f265
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 35 deletions.
6 changes: 6 additions & 0 deletions providers/github/resources/github.lr
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ private github.repository @defaults("fullName") {
closedIssues() []github.issue
// Repository license
license() github.license
// Whether the update branch button is enabled
allowUpdateBranch bool
// Whether commit signatures are required for commits
webCommitSignoffRequired bool
// Whether deleting pull request branches after merging a pull request is enabled
deleteBranchOnMerge bool
}

// GitHub license
Expand Down
36 changes: 36 additions & 0 deletions providers/github/resources/github.lr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions providers/github/resources/github.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ resources:
min_mondoo_version: 6.4.0
allowSquashMerge:
min_mondoo_version: 6.4.0
allowUpdateBranch:
min_mondoo_version: 9.0.0
archived: {}
branches:
min_mondoo_version: 6.4.0
Expand All @@ -325,6 +327,8 @@ resources:
createdAt: {}
defaultBranchName:
min_mondoo_version: 6.4.0
deleteBranchOnMerge:
min_mondoo_version: 9.0.0
description: {}
disabled: {}
files:
Expand Down Expand Up @@ -384,6 +388,8 @@ resources:
visibility: {}
watchersCount:
min_mondoo_version: 7.14.0
webCommitSignoffRequired:
min_mondoo_version: 9.0.0
webhooks:
min_mondoo_version: 6.11.0
workflows:
Expand Down
73 changes: 38 additions & 35 deletions providers/github/resources/github_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,41 +34,44 @@ func newMqlGithubRepository(runtime *plugin.Runtime, repo *github.Repository) (*
}

res, err := CreateResource(runtime, "github.repository", map[string]*llx.RawData{
"id": llx.IntData(id),
"name": llx.StringDataPtr(repo.Name),
"fullName": llx.StringDataPtr(repo.FullName),
"description": llx.StringDataPtr(repo.Description),
"homepage": llx.StringDataPtr(repo.Homepage),
"topics": llx.ArrayData(convert.SliceAnyToInterface[string](repo.Topics), types.String),
"language": llx.StringData(repo.GetLanguage()),
"createdAt": llx.TimeDataPtr(githubTimestamp(repo.CreatedAt)),
"updatedAt": llx.TimeDataPtr(githubTimestamp(repo.UpdatedAt)),
"pushedAt": llx.TimeDataPtr(githubTimestamp(repo.PushedAt)),
"archived": llx.BoolDataPtr(repo.Archived),
"disabled": llx.BoolDataPtr(repo.Disabled),
"private": llx.BoolDataPtr(repo.Private),
"isFork": llx.BoolDataPtr(repo.Fork),
"watchersCount": llx.IntData(int64(repo.GetWatchersCount())),
"forksCount": llx.IntData(int64(repo.GetForksCount())),
"openIssuesCount": llx.IntData(int64(repo.GetOpenIssues())),
"stargazersCount": llx.IntData(int64(repo.GetStargazersCount())),
"visibility": llx.StringDataPtr(repo.Visibility),
"allowAutoMerge": llx.BoolDataPtr(repo.AllowAutoMerge),
"allowForking": llx.BoolDataPtr(repo.AllowForking),
"allowMergeCommit": llx.BoolDataPtr(repo.AllowMergeCommit),
"allowRebaseMerge": llx.BoolDataPtr(repo.AllowRebaseMerge),
"allowSquashMerge": llx.BoolDataPtr(repo.AllowSquashMerge),
"hasIssues": llx.BoolData(repo.GetHasIssues()),
"hasProjects": llx.BoolData(repo.GetHasProjects()),
"hasWiki": llx.BoolData(repo.GetHasWiki()),
"hasPages": llx.BoolData(repo.GetHasPages()),
"hasDownloads": llx.BoolData(repo.GetHasDownloads()),
"hasDiscussions": llx.BoolData(repo.GetHasDiscussions()),
"isTemplate": llx.BoolData(repo.GetIsTemplate()),
"defaultBranchName": llx.StringDataPtr(repo.DefaultBranch),
"cloneUrl": llx.StringData(repo.GetCloneURL()),
"sshUrl": llx.StringData(repo.GetSSHURL()),
"owner": llx.ResourceData(owner, owner.MqlName()),
"id": llx.IntData(id),
"name": llx.StringDataPtr(repo.Name),
"fullName": llx.StringDataPtr(repo.FullName),
"description": llx.StringDataPtr(repo.Description),
"homepage": llx.StringDataPtr(repo.Homepage),
"topics": llx.ArrayData(convert.SliceAnyToInterface[string](repo.Topics), types.String),
"language": llx.StringData(repo.GetLanguage()),
"createdAt": llx.TimeDataPtr(githubTimestamp(repo.CreatedAt)),
"updatedAt": llx.TimeDataPtr(githubTimestamp(repo.UpdatedAt)),
"pushedAt": llx.TimeDataPtr(githubTimestamp(repo.PushedAt)),
"archived": llx.BoolDataPtr(repo.Archived),
"disabled": llx.BoolDataPtr(repo.Disabled),
"private": llx.BoolDataPtr(repo.Private),
"isFork": llx.BoolDataPtr(repo.Fork),
"watchersCount": llx.IntData(int64(repo.GetWatchersCount())),
"forksCount": llx.IntData(int64(repo.GetForksCount())),
"openIssuesCount": llx.IntData(int64(repo.GetOpenIssues())),
"stargazersCount": llx.IntData(int64(repo.GetStargazersCount())),
"visibility": llx.StringDataPtr(repo.Visibility),
"allowAutoMerge": llx.BoolData(convert.ToBool(repo.AllowAutoMerge)),
"allowForking": llx.BoolData(convert.ToBool(repo.AllowForking)),
"allowMergeCommit": llx.BoolData(convert.ToBool(repo.AllowMergeCommit)),
"allowRebaseMerge": llx.BoolData(convert.ToBool(repo.AllowRebaseMerge)),
"allowSquashMerge": llx.BoolData(convert.ToBool(repo.AllowSquashMerge)),
"allowUpdateBranch": llx.BoolData(convert.ToBool(repo.AllowUpdateBranch)),
"webCommitSignoffRequired": llx.BoolData(convert.ToBool(repo.WebCommitSignoffRequired)),
"deleteBranchOnMerge": llx.BoolData(convert.ToBool(repo.DeleteBranchOnMerge)),
"hasIssues": llx.BoolData(repo.GetHasIssues()),
"hasProjects": llx.BoolData(repo.GetHasProjects()),
"hasWiki": llx.BoolData(repo.GetHasWiki()),
"hasPages": llx.BoolData(repo.GetHasPages()),
"hasDownloads": llx.BoolData(repo.GetHasDownloads()),
"hasDiscussions": llx.BoolData(repo.GetHasDiscussions()),
"isTemplate": llx.BoolData(repo.GetIsTemplate()),
"defaultBranchName": llx.StringDataPtr(repo.DefaultBranch),
"cloneUrl": llx.StringData(repo.GetCloneURL()),
"sshUrl": llx.StringData(repo.GetSSHURL()),
"owner": llx.ResourceData(owner, owner.MqlName()),
})
if err != nil {
return nil, err
Expand Down

0 comments on commit 351f265

Please sign in to comment.