From b0b0b62c4b7c3a08be9fac61cfe0f9cafa235ba8 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Thu, 14 Nov 2024 12:06:13 -0700 Subject: [PATCH] Expand fields for GitLab project Get some more data Signed-off-by: Tim Smith --- providers/gitlab/resources/gitlab.go | 1 + providers/gitlab/resources/gitlab.lr | 6 ++++-- providers/gitlab/resources/gitlab.lr.go | 12 ++++++++++++ providers/gitlab/resources/gitlab.lr.manifest.yaml | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/providers/gitlab/resources/gitlab.go b/providers/gitlab/resources/gitlab.go index a5bcd26f3d..77fbe6e1c9 100644 --- a/providers/gitlab/resources/gitlab.go +++ b/providers/gitlab/resources/gitlab.go @@ -141,6 +141,7 @@ func (p *mqlGitlabProject) approvalSettings() (*mqlGitlabProjectApprovalSetting, "mergeRequestsAuthorApproval": llx.BoolData(approvalConfig.MergeRequestsAuthorApproval), "mergeRequestsDisableCommittersApproval": llx.BoolData(approvalConfig.MergeRequestsDisableCommittersApproval), "requirePasswordToApprove": llx.BoolData(approvalConfig.RequirePasswordToApprove), + "selectiveCodeOwnerRemovals": llx.BoolData(approvalConfig.SelectiveCodeOwnerRemovals), } mqlApprovalSettings, err := CreateResource(p.MqlRuntime, "gitlab.project.approvalSetting", approvalSettings) diff --git a/providers/gitlab/resources/gitlab.lr b/providers/gitlab/resources/gitlab.lr index 4873dd798c..cf3ee02fe2 100644 --- a/providers/gitlab/resources/gitlab.lr +++ b/providers/gitlab/resources/gitlab.lr @@ -43,7 +43,7 @@ gitlab.project @defaults("fullName visibility webURL") { // Project path path string // Create date of the project - createdAt time + createdAt time // Project description description string // Default Git branch @@ -123,6 +123,8 @@ private gitlab.project.approvalSetting @defaults("approvalsBeforeMerge requirePa mergeRequestsDisableCommittersApproval bool // Whether a password is required to approve requirePasswordToApprove bool + // DEETS + selectiveCodeOwnerRemovals bool } @@ -166,4 +168,4 @@ private gitlab.project.webhook @defaults("url sslVerification") { url string // Whether SSL verification is enabled sslVerification bool -} \ No newline at end of file +} diff --git a/providers/gitlab/resources/gitlab.lr.go b/providers/gitlab/resources/gitlab.lr.go index 2bed7e1228..4dd826cf8f 100644 --- a/providers/gitlab/resources/gitlab.lr.go +++ b/providers/gitlab/resources/gitlab.lr.go @@ -274,6 +274,9 @@ var getDataFields = map[string]func(r plugin.Resource) *plugin.DataRes{ "gitlab.project.approvalSetting.requirePasswordToApprove": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlGitlabProjectApprovalSetting).GetRequirePasswordToApprove()).ToDataRes(types.Bool) }, + "gitlab.project.approvalSetting.selectiveCodeOwnerRemovals": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlGitlabProjectApprovalSetting).GetSelectiveCodeOwnerRemovals()).ToDataRes(types.Bool) + }, "gitlab.project.protectedBranch.name": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlGitlabProjectProtectedBranch).GetName()).ToDataRes(types.String) }, @@ -549,6 +552,10 @@ var setDataFields = map[string]func(r plugin.Resource, v *llx.RawData) bool { r.(*mqlGitlabProjectApprovalSetting).RequirePasswordToApprove, ok = plugin.RawToTValue[bool](v.Value, v.Error) return }, + "gitlab.project.approvalSetting.selectiveCodeOwnerRemovals": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlGitlabProjectApprovalSetting).SelectiveCodeOwnerRemovals, ok = plugin.RawToTValue[bool](v.Value, v.Error) + return + }, "gitlab.project.protectedBranch.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { r.(*mqlGitlabProjectProtectedBranch).__id, ok = v.Value.(string) return @@ -1095,6 +1102,7 @@ type mqlGitlabProjectApprovalSetting struct { MergeRequestsAuthorApproval plugin.TValue[bool] MergeRequestsDisableCommittersApproval plugin.TValue[bool] RequirePasswordToApprove plugin.TValue[bool] + SelectiveCodeOwnerRemovals plugin.TValue[bool] } // createGitlabProjectApprovalSetting creates a new instance of this resource @@ -1153,6 +1161,10 @@ func (c *mqlGitlabProjectApprovalSetting) GetRequirePasswordToApprove() *plugin. return &c.RequirePasswordToApprove } +func (c *mqlGitlabProjectApprovalSetting) GetSelectiveCodeOwnerRemovals() *plugin.TValue[bool] { + return &c.SelectiveCodeOwnerRemovals +} + // mqlGitlabProjectProtectedBranch for the gitlab.project.protectedBranch resource type mqlGitlabProjectProtectedBranch struct { MqlRuntime *plugin.Runtime diff --git a/providers/gitlab/resources/gitlab.lr.manifest.yaml b/providers/gitlab/resources/gitlab.lr.manifest.yaml index 481031e6d9..18f09f0aa9 100755 --- a/providers/gitlab/resources/gitlab.lr.manifest.yaml +++ b/providers/gitlab/resources/gitlab.lr.manifest.yaml @@ -99,6 +99,7 @@ resources: mergeRequestsDisableCommittersApproval: {} requirePasswordToApprove: {} resetApprovalsOnPush: {} + selectiveCodeOwnerRemovals: {} is_private: true min_mondoo_version: 9.0.0 gitlab.project.file: