Branch Protection Args
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";
const branchProtect = new gitlab.BranchProtection("BranchProtect", {
project: "12345",
branch: "BranchProtected",
pushAccessLevel: "developer",
mergeAccessLevel: "developer",
unprotectAccessLevel: "developer",
allowForcePush: true,
codeOwnerApprovalRequired: true,
allowedToPushes: [
{
userId: 5,
},
{
userId: 521,
},
],
allowedToMerges: [
{
userId: 15,
},
{
userId: 37,
},
],
allowedToUnprotects: [
{
userId: 15,
},
{
groupId: 42,
},
],
});
// Example using dynamic block
const main = new gitlab.BranchProtection("main", {
allowedToPushes: [
50,
55,
60,
].map((v, k) => ({key: k, value: v})).map(entry => ({
userId: entry.value,
})),
project: "12345",
branch: "main",
pushAccessLevel: "maintainer",
mergeAccessLevel: "maintainer",
unprotectAccessLevel: "maintainer",
});
import pulumi
import pulumi_gitlab as gitlab
branch_protect = gitlab.BranchProtection("BranchProtect",
project="12345",
branch="BranchProtected",
push_access_level="developer",
merge_access_level="developer",
unprotect_access_level="developer",
allow_force_push=True,
code_owner_approval_required=True,
allowed_to_pushes=[
gitlab.BranchProtectionAllowedToPushArgs(
user_id=5,
),
gitlab.BranchProtectionAllowedToPushArgs(
user_id=521,
),
],
allowed_to_merges=[
gitlab.BranchProtectionAllowedToMergeArgs(
user_id=15,
),
gitlab.BranchProtectionAllowedToMergeArgs(
user_id=37,
),
],
allowed_to_unprotects=[
gitlab.BranchProtectionAllowedToUnprotectArgs(
user_id=15,
),
gitlab.BranchProtectionAllowedToUnprotectArgs(
group_id=42,
),
])
# Example using dynamic block
main = gitlab.BranchProtection("main",
allowed_to_pushes=[gitlab.BranchProtectionAllowedToPushArgs(
user_id=entry["value"],
) for entry in [{"key": k, "value": v} for k, v in [
50,
55,
60,
]]],
project="12345",
branch="main",
push_access_level="maintainer",
merge_access_level="maintainer",
unprotect_access_level="maintainer")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using GitLab = Pulumi.GitLab;
return await Deployment.RunAsync(() =>
{
var branchProtect = new GitLab.BranchProtection("BranchProtect", new()
{
Project = "12345",
Branch = "BranchProtected",
PushAccessLevel = "developer",
MergeAccessLevel = "developer",
UnprotectAccessLevel = "developer",
AllowForcePush = true,
CodeOwnerApprovalRequired = true,
AllowedToPushes = new[]
{
new GitLab.Inputs.BranchProtectionAllowedToPushArgs
{
UserId = 5,
},
new GitLab.Inputs.BranchProtectionAllowedToPushArgs
{
UserId = 521,
},
},
AllowedToMerges = new[]
{
new GitLab.Inputs.BranchProtectionAllowedToMergeArgs
{
UserId = 15,
},
new GitLab.Inputs.BranchProtectionAllowedToMergeArgs
{
UserId = 37,
},
},
AllowedToUnprotects = new[]
{
new GitLab.Inputs.BranchProtectionAllowedToUnprotectArgs
{
UserId = 15,
},
new GitLab.Inputs.BranchProtectionAllowedToUnprotectArgs
{
GroupId = 42,
},
},
});
// Example using dynamic block
var main = new GitLab.BranchProtection("main", new()
{
AllowedToPushes = new[]
{
50,
55,
60,
}.Select((v, k) => new { Key = k, Value = v }).Select(entry =>
{
return new GitLab.Inputs.BranchProtectionAllowedToPushArgs
{
UserId = entry.Value,
};
}).ToList(),
Project = "12345",
Branch = "main",
PushAccessLevel = "maintainer",
MergeAccessLevel = "maintainer",
UnprotectAccessLevel = "maintainer",
});
});
Import
Gitlab protected branches can be imported with a key composed of <project_id>:<branch>
, e.g.
$ pulumi import gitlab:index/branchProtection:BranchProtection BranchProtect "12345:main"
Constructors
Properties
Array of access levels and user(s)/group(s) allowed to merge to protected branch.
Array of access levels and user(s)/group(s) allowed to push to protected branch.
Array of access levels and user(s)/group(s) allowed to unprotect push to protected branch.
Can be set to true to allow users with push access to force push.
Can be set to true to require code owner approval before merging. Only available for Premium and Ultimate instances.
Access levels allowed to merge. Valid values are: no one
, developer
, maintainer
.
Access levels allowed to push. Valid values are: no one
, developer
, maintainer
.
Access levels allowed to unprotect. Valid values are: developer
, maintainer
, admin
.