UNPKG

@pulumi/github

Version:

A Pulumi package for creating and managing github cloud resources.

141 lines 6.76 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.BranchProtection = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as github from "@pulumi/github"; * * const exampleRepository = new github.Repository("example", {name: "test"}); * const example = github.getUser({ * username: "example", * }); * const exampleTeam = new github.Team("example", {name: "Example Name"}); * // Protect the main branch of the foo repository. Additionally, require that * // the "ci/travis" context to be passing and only allow the engineers team merge * // to the branch. * const exampleBranchProtection = new github.BranchProtection("example", { * repositoryId: exampleRepository.nodeId, * pattern: "main", * enforceAdmins: true, * allowsDeletions: true, * requiredStatusChecks: [{ * strict: false, * contexts: ["ci/travis"], * }], * requiredPullRequestReviews: [{ * dismissStaleReviews: true, * restrictDismissals: true, * dismissalRestrictions: [ * example.then(example => example.nodeId), * exampleTeam.nodeId, * "/exampleuser", * "exampleorganization/exampleteam", * ], * }], * restrictPushes: [{ * pushAllowances: [ * example.then(example => example.nodeId), * "/exampleuser", * "exampleorganization/exampleteam", * ], * }], * forcePushBypassers: [ * example.then(example => example.nodeId), * "/exampleuser", * "exampleorganization/exampleteam", * ], * }); * const exampleTeamRepository = new github.TeamRepository("example", { * teamId: exampleTeam.id, * repository: exampleRepository.name, * permission: "pull", * }); * ``` * * ## Import * * GitHub Branch Protection can be imported using an ID made up of `repository:pattern`, e.g. * * ```sh * $ pulumi import github:index/branchProtection:BranchProtection terraform terraform:main * ``` */ class BranchProtection extends pulumi.CustomResource { /** * Get an existing BranchProtection resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new BranchProtection(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of BranchProtection. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === BranchProtection.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["allowsDeletions"] = state ? state.allowsDeletions : undefined; resourceInputs["allowsForcePushes"] = state ? state.allowsForcePushes : undefined; resourceInputs["enforceAdmins"] = state ? state.enforceAdmins : undefined; resourceInputs["forcePushBypassers"] = state ? state.forcePushBypassers : undefined; resourceInputs["lockBranch"] = state ? state.lockBranch : undefined; resourceInputs["pattern"] = state ? state.pattern : undefined; resourceInputs["repositoryId"] = state ? state.repositoryId : undefined; resourceInputs["requireConversationResolution"] = state ? state.requireConversationResolution : undefined; resourceInputs["requireSignedCommits"] = state ? state.requireSignedCommits : undefined; resourceInputs["requiredLinearHistory"] = state ? state.requiredLinearHistory : undefined; resourceInputs["requiredPullRequestReviews"] = state ? state.requiredPullRequestReviews : undefined; resourceInputs["requiredStatusChecks"] = state ? state.requiredStatusChecks : undefined; resourceInputs["restrictPushes"] = state ? state.restrictPushes : undefined; } else { const args = argsOrState; if ((!args || args.pattern === undefined) && !opts.urn) { throw new Error("Missing required property 'pattern'"); } if ((!args || args.repositoryId === undefined) && !opts.urn) { throw new Error("Missing required property 'repositoryId'"); } resourceInputs["allowsDeletions"] = args ? args.allowsDeletions : undefined; resourceInputs["allowsForcePushes"] = args ? args.allowsForcePushes : undefined; resourceInputs["enforceAdmins"] = args ? args.enforceAdmins : undefined; resourceInputs["forcePushBypassers"] = args ? args.forcePushBypassers : undefined; resourceInputs["lockBranch"] = args ? args.lockBranch : undefined; resourceInputs["pattern"] = args ? args.pattern : undefined; resourceInputs["repositoryId"] = args ? args.repositoryId : undefined; resourceInputs["requireConversationResolution"] = args ? args.requireConversationResolution : undefined; resourceInputs["requireSignedCommits"] = args ? args.requireSignedCommits : undefined; resourceInputs["requiredLinearHistory"] = args ? args.requiredLinearHistory : undefined; resourceInputs["requiredPullRequestReviews"] = args ? args.requiredPullRequestReviews : undefined; resourceInputs["requiredStatusChecks"] = args ? args.requiredStatusChecks : undefined; resourceInputs["restrictPushes"] = args ? args.restrictPushes : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(BranchProtection.__pulumiType, name, resourceInputs, opts); } } exports.BranchProtection = BranchProtection; /** @internal */ BranchProtection.__pulumiType = 'github:index/branchProtection:BranchProtection'; //# sourceMappingURL=branchProtection.js.map