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

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gitlab.BranchProtection;
import com.pulumi.gitlab.BranchProtectionArgs;
import com.pulumi.gitlab.inputs.BranchProtectionAllowedToPushArgs;
import com.pulumi.gitlab.inputs.BranchProtectionAllowedToMergeArgs;
import com.pulumi.gitlab.inputs.BranchProtectionAllowedToUnprotectArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var branchProtect = new BranchProtection("branchProtect", BranchProtectionArgs.builder()
.project("12345")
.branch("BranchProtected")
.pushAccessLevel("developer")
.mergeAccessLevel("developer")
.unprotectAccessLevel("developer")
.allowForcePush(true)
.codeOwnerApprovalRequired(true)
.allowedToPushes(
BranchProtectionAllowedToPushArgs.builder()
.userId(5)
.build(),
BranchProtectionAllowedToPushArgs.builder()
.userId(521)
.build())
.allowedToMerges(
BranchProtectionAllowedToMergeArgs.builder()
.userId(15)
.build(),
BranchProtectionAllowedToMergeArgs.builder()
.userId(37)
.build())
.allowedToUnprotects(
BranchProtectionAllowedToUnprotectArgs.builder()
.userId(15)
.build(),
BranchProtectionAllowedToUnprotectArgs.builder()
.groupId(42)
.build())
.build());
// Example using dynamic block
var main = new BranchProtection("main", BranchProtectionArgs.builder()
.project("12345")
.branch("main")
.pushAccessLevel("maintainer")
.mergeAccessLevel("maintainer")
.unprotectAccessLevel("maintainer")
.dynamic(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference))
.build());
}
}
resources:
branchProtect:
type: gitlab:BranchProtection
properties:
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
main:
type: gitlab:BranchProtection
properties:
project: '12345'
branch: main
pushAccessLevel: maintainer
mergeAccessLevel: maintainer
unprotectAccessLevel: maintainer
dynamic:
- forEach:
- 50
- 55
- 60
content:
- userId: ${allowed_to_push.value}

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

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