@pulumi/github
Version:
A Pulumi package for creating and managing github cloud resources.
102 lines • 5.11 kB
JavaScript
// *** 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.BranchProtectionV3 = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Protects a GitHub branch.
*
* The `github.BranchProtection` resource has moved to the GraphQL API, while this resource will continue to leverage the REST API.
*
* This resource allows you to configure branch protection for repositories in your organization. When applied, the branch will be protected from forced pushes and deletion. Additional constraints, such as required status checks or restrictions on users, teams, and apps, can also be configured.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as github from "@pulumi/github";
*
* // Protect the main branch of the foo repository. Only allow a specific user to merge to the branch.
* const example = new github.BranchProtectionV3("example", {
* repository: exampleGithubRepository.name,
* branch: "main",
* restrictions: {
* users: ["foo-user"],
* },
* });
* ```
*
* ## Import
*
* GitHub Branch Protection can be imported using an ID made up of `repository:branch`, e.g.
*
* ```sh
* $ pulumi import github:index/branchProtectionV3:BranchProtectionV3 terraform terraform:main
* ```
*/
class BranchProtectionV3 extends pulumi.CustomResource {
/**
* Get an existing BranchProtectionV3 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 BranchProtectionV3(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of BranchProtectionV3. 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'] === BranchProtectionV3.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["branch"] = state ? state.branch : undefined;
resourceInputs["enforceAdmins"] = state ? state.enforceAdmins : undefined;
resourceInputs["etag"] = state ? state.etag : undefined;
resourceInputs["repository"] = state ? state.repository : undefined;
resourceInputs["requireConversationResolution"] = state ? state.requireConversationResolution : undefined;
resourceInputs["requireSignedCommits"] = state ? state.requireSignedCommits : undefined;
resourceInputs["requiredPullRequestReviews"] = state ? state.requiredPullRequestReviews : undefined;
resourceInputs["requiredStatusChecks"] = state ? state.requiredStatusChecks : undefined;
resourceInputs["restrictions"] = state ? state.restrictions : undefined;
}
else {
const args = argsOrState;
if ((!args || args.branch === undefined) && !opts.urn) {
throw new Error("Missing required property 'branch'");
}
if ((!args || args.repository === undefined) && !opts.urn) {
throw new Error("Missing required property 'repository'");
}
resourceInputs["branch"] = args ? args.branch : undefined;
resourceInputs["enforceAdmins"] = args ? args.enforceAdmins : undefined;
resourceInputs["repository"] = args ? args.repository : undefined;
resourceInputs["requireConversationResolution"] = args ? args.requireConversationResolution : undefined;
resourceInputs["requireSignedCommits"] = args ? args.requireSignedCommits : undefined;
resourceInputs["requiredPullRequestReviews"] = args ? args.requiredPullRequestReviews : undefined;
resourceInputs["requiredStatusChecks"] = args ? args.requiredStatusChecks : undefined;
resourceInputs["restrictions"] = args ? args.restrictions : undefined;
resourceInputs["etag"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(BranchProtectionV3.__pulumiType, name, resourceInputs, opts);
}
}
exports.BranchProtectionV3 = BranchProtectionV3;
/** @internal */
BranchProtectionV3.__pulumiType = 'github:index/branchProtectionV3:BranchProtectionV3';
//# sourceMappingURL=branchProtectionV3.js.map
;