-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable gitlab pipeline mr protection
Signed-off-by: makkalot <[email protected]>
- Loading branch information
Showing
6 changed files
with
195 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright The Linux Foundation and each contributor to CommunityBridge. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/aws/aws-lambda-go/events" | ||
log "github.com/communitybridge/easycla/cla-backend-go/logging" | ||
) | ||
|
||
func main() { | ||
event := events.DynamoDBEvent{ | ||
Records: []events.DynamoDBEventRecord{ | ||
{ | ||
EventSourceArn: "aws:dynamodb/cla-dev-gitlab-orgs", | ||
EventName: "MODIFY", | ||
EventSource: "aws:dynamodb", | ||
Change: events.DynamoDBStreamRecord{ | ||
OldImage: map[string]events.DynamoDBAttributeValue{ | ||
"organization_id": events.NewStringAttribute("4ace6f9f-0518-4621-ae86-d0dacc75af83"), | ||
"organization_full_path": events.NewStringAttribute("penguinsoft"), | ||
"organization_sfid": events.NewStringAttribute("a092M00001If9uZQAR"), | ||
"auto_enabled_cla_group_id": events.NewStringAttribute("40af3652-e8bf-489d-a917-cb2214a89640"), | ||
"external_gitlab_group_id": events.NewNumberAttribute("12700028"), | ||
"auth_state": events.NewStringAttribute("18eb90d1-8c36-4962-ba91-e264ccbcab3a"), | ||
"organization_url": events.NewStringAttribute("https://gitlab.com/groups/penguinsoft"), | ||
"auth_info": events.NewStringAttribute("f0a41dbee58c25569da8aa6a09aa54f7b12de5ef664b12721c08a6dfb0fca7bb59a738b2c2220364d601d12ad2aabedcb6fc7b012c52dc221c5fa60b098604dd408253cc79dd2764ad61a2853f77fd54abb53d42e6f064c8106423fee7542fda60802bd7afa4b0ccaa9e1fc788e9eeae118fb61fae21e86c02eef904701eb77597dfebd985554a3a9d3c9ccd67016eb80536df6a56deaeb169213e1264d75b92cf55740624b3588671580dd854ea4e8c819be3a3bdae736152fca4b7cc477bef1a0c4a1bf42c77a9c9c5e1942176c55da467ff3ad73064f9a460cb866007f961be2bc261f769f79ee357221d3a80a5df953970"), | ||
"organization_name_lower": events.NewStringAttribute("penguinsoft"), | ||
"project_sfid": events.NewStringAttribute("a092M00001If9uZQAR"), | ||
"organization_name": events.NewStringAttribute("penguinsoft"), | ||
"enabled": events.NewBooleanAttribute(false), | ||
"auto_enabled": events.NewBooleanAttribute(false), | ||
"branch_protection_enabled": events.NewBooleanAttribute(false), | ||
}, | ||
NewImage: map[string]events.DynamoDBAttributeValue{ | ||
"organization_id": events.NewStringAttribute("4ace6f9f-0518-4621-ae86-d0dacc75af83"), | ||
"organization_full_path": events.NewStringAttribute("penguinsoft"), | ||
"organization_sfid": events.NewStringAttribute("a092M00001If9uZQAR"), | ||
"auto_enabled_cla_group_id": events.NewStringAttribute("40af3652-e8bf-489d-a917-cb2214a89640"), | ||
"external_gitlab_group_id": events.NewNumberAttribute("12700028"), | ||
"auth_state": events.NewStringAttribute("18eb90d1-8c36-4962-ba91-e264ccbcab3a"), | ||
"organization_url": events.NewStringAttribute("https://gitlab.com/groups/penguinsoft"), | ||
"auth_info": events.NewStringAttribute("f0a41dbee58c25569da8aa6a09aa54f7b12de5ef664b12721c08a6dfb0fca7bb59a738b2c2220364d601d12ad2aabedcb6fc7b012c52dc221c5fa60b098604dd408253cc79dd2764ad61a2853f77fd54abb53d42e6f064c8106423fee7542fda60802bd7afa4b0ccaa9e1fc788e9eeae118fb61fae21e86c02eef904701eb77597dfebd985554a3a9d3c9ccd67016eb80536df6a56deaeb169213e1264d75b92cf55740624b3588671580dd854ea4e8c819be3a3bdae736152fca4b7cc477bef1a0c4a1bf42c77a9c9c5e1942176c55da467ff3ad73064f9a460cb866007f961be2bc261f769f79ee357221d3a80a5df953970"), | ||
"organization_name_lower": events.NewStringAttribute("penguinsoft"), | ||
"project_sfid": events.NewStringAttribute("a092M00001If9uZQAR"), | ||
"organization_name": events.NewStringAttribute("penguinsoft"), | ||
"enabled": events.NewBooleanAttribute(true), | ||
"auto_enabled": events.NewBooleanAttribute(false), | ||
"branch_protection_enabled": events.NewBooleanAttribute(true), | ||
}, | ||
}}, | ||
}, | ||
} | ||
|
||
b, err := json.Marshal(event) | ||
if err != nil { | ||
log.Fatalf("marshall : %v", err) | ||
} | ||
|
||
log.Println(string(b)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright The Linux Foundation and each contributor to CommunityBridge. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
gitlab_api "github.com/communitybridge/easycla/cla-backend-go/gitlab_api" | ||
log "github.com/communitybridge/easycla/cla-backend-go/logging" | ||
"github.com/xanzy/go-gitlab" | ||
"os" | ||
) | ||
|
||
var projectID = flag.Int("project", 0, "gitlab project id") | ||
|
||
func main() { | ||
flag.Parse() | ||
|
||
if *projectID == 0 { | ||
log.Fatalf("gitlab project id is missing") | ||
} | ||
|
||
accessToken := os.Getenv("GITLAB_ACCESS_TOKEN") | ||
if accessToken == "" { | ||
log.Fatalf("GITLAB_ACCESS_TOKEN is required") | ||
} | ||
|
||
gitlabClient, err := gitlab.NewOAuthClient(accessToken) | ||
if err != nil { | ||
log.Fatalf("creating client failed : %v", err) | ||
} | ||
|
||
if err := gitlab_api.EnableMergePipelineProtection(context.Background(), gitlabClient, *projectID); err != nil { | ||
log.Fatalf("enabling merge pipeline protection failed : %v") | ||
} | ||
|
||
log.Println("merge pipeline protection enabled successfully") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright The Linux Foundation and each contributor to CommunityBridge. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/aws/aws-lambda-go/events" | ||
log "github.com/communitybridge/easycla/cla-backend-go/logging" | ||
) | ||
|
||
func main() { | ||
event := events.DynamoDBEvent{ | ||
Records: []events.DynamoDBEventRecord{ | ||
{ | ||
EventSourceArn: "aws:dynamodb/cla-dev-repositories", | ||
EventName: "MODIFY", | ||
EventSource: "aws:dynamodb", | ||
Change: events.DynamoDBStreamRecord{ | ||
OldImage: map[string]events.DynamoDBAttributeValue{ | ||
"repository_id": events.NewStringAttribute("1fa3de39-8274-4750-ba7c-242d5d659dd1"), | ||
"repository_name": events.NewStringAttribute("easycla-gitlab-test"), | ||
"repository_organization_name": events.NewStringAttribute("penguinsoft"), | ||
"repository_project_id": events.NewStringAttribute("40af3652-e8bf-489d-a917-cb2214a89640"), | ||
"repository_sfdc_id": events.NewStringAttribute("a092M00001If9uZQAR"), | ||
"project_sfid": events.NewStringAttribute("a092M00001If9uZQAR"), | ||
"repository_external_id": events.NewNumberAttribute("28893091"), | ||
"repository_type": events.NewStringAttribute("gitlab"), | ||
"enabled": events.NewBooleanAttribute(false), | ||
}, | ||
NewImage: map[string]events.DynamoDBAttributeValue{ | ||
"repository_id": events.NewStringAttribute("1fa3de39-8274-4750-ba7c-242d5d659dd1"), | ||
"repository_name": events.NewStringAttribute("easycla-gitlab-test"), | ||
"repository_organization_name": events.NewStringAttribute("penguinsoft"), | ||
"repository_project_id": events.NewStringAttribute("40af3652-e8bf-489d-a917-cb2214a89640"), | ||
"repository_sfdc_id": events.NewStringAttribute("a092M00001If9uZQAR"), | ||
"project_sfid": events.NewStringAttribute("a092M00001If9uZQAR"), | ||
"repository_external_id": events.NewNumberAttribute("28893091"), | ||
"repository_type": events.NewStringAttribute("gitlab"), | ||
"enabled": events.NewBooleanAttribute(true), | ||
}, | ||
}}, | ||
}, | ||
} | ||
|
||
b, err := json.Marshal(event) | ||
if err != nil { | ||
log.Fatalf("marshall : %v", err) | ||
} | ||
|
||
log.Println(string(b)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters