BranchProtectionArgs

data class BranchProtectionArgs(val allowForcePush: Output<Boolean>? = null, val allowedToMerges: Output<List<BranchProtectionAllowedToMergeArgs>>? = null, val allowedToPushes: Output<List<BranchProtectionAllowedToPushArgs>>? = null, val allowedToUnprotects: Output<List<BranchProtectionAllowedToUnprotectArgs>>? = null, val branch: Output<String>? = null, val codeOwnerApprovalRequired: Output<Boolean>? = null, val mergeAccessLevel: Output<String>? = null, val project: Output<String>? = null, val pushAccessLevel: Output<String>? = null, val unprotectAccessLevel: Output<String>? = null) : ConvertibleToJava<BranchProtectionArgs>

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=[
{
"user_id": 5,
},
{
"user_id": 521,
},
],
allowed_to_merges=[
{
"user_id": 15,
},
{
"user_id": 37,
},
],
allowed_to_unprotects=[
{
"user_id": 15,
},
{
"group_id": 42,
},
])
# Example using dynamic block
main = gitlab.BranchProtection("main",
allowed_to_pushes=[{
"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

Starting in Terraform v1.5.0 you can use an import block to import gitlab_branch_protection. For example: terraform import { to = gitlab_branch_protection.example id = "see CLI command below for ID" } Import using the CLI is supported using the following syntax: 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

Link copied to clipboard
constructor(allowForcePush: Output<Boolean>? = null, allowedToMerges: Output<List<BranchProtectionAllowedToMergeArgs>>? = null, allowedToPushes: Output<List<BranchProtectionAllowedToPushArgs>>? = null, allowedToUnprotects: Output<List<BranchProtectionAllowedToUnprotectArgs>>? = null, branch: Output<String>? = null, codeOwnerApprovalRequired: Output<Boolean>? = null, mergeAccessLevel: Output<String>? = null, project: Output<String>? = null, pushAccessLevel: Output<String>? = null, unprotectAccessLevel: Output<String>? = null)

Properties

Link copied to clipboard

Array of access levels and user(s)/group(s) allowed to merge to protected branch.

Link copied to clipboard

Array of access levels and user(s)/group(s) allowed to push to protected branch.

Link copied to clipboard

Array of access levels and user(s)/group(s) allowed to unprotect push to protected branch.

Link copied to clipboard
val allowForcePush: Output<Boolean>? = null

Can be set to true to allow users with push access to force push.

Link copied to clipboard
val branch: Output<String>? = null

Name of the branch.

Link copied to clipboard
val codeOwnerApprovalRequired: Output<Boolean>? = null

Can be set to true to require code owner approval before merging. Only available for Premium and Ultimate instances.

Link copied to clipboard
val mergeAccessLevel: Output<String>? = null

Access levels allowed to merge. Valid values are: no one, developer, maintainer.

Link copied to clipboard
val project: Output<String>? = null

The id of the project.

Link copied to clipboard
val pushAccessLevel: Output<String>? = null

Access levels allowed to push. Valid values are: no one, developer, maintainer.

Link copied to clipboard
val unprotectAccessLevel: Output<String>? = null

Access levels allowed to unprotect. Valid values are: developer, maintainer, admin.

Functions

Link copied to clipboard
open override fun toJava(): BranchProtectionArgs