@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
184 lines • 8.55 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.BranchRule = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* BranchRule is the protection rule to enforce pre-defined rules on designated branches within a repository.
*
* To get more information about BranchRule, see:
*
* * [API documentation](https://cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/secure-source-manager/docs/overview)
*
* ## Example Usage
*
* ### Secure Source Manager Branch Rule Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const instance = new gcp.securesourcemanager.Instance("instance", {
* location: "us-central1",
* instanceId: "my-basic-instance",
* });
* const repository = new gcp.securesourcemanager.Repository("repository", {
* repositoryId: "my-basic-repository",
* location: instance.location,
* instance: instance.name,
* });
* const basic = new gcp.securesourcemanager.BranchRule("basic", {
* branchRuleId: "my-basic-branchrule",
* repositoryId: repository.repositoryId,
* location: repository.location,
* includePattern: "main",
* });
* ```
* ### Secure Source Manager Branch Rule With Fields
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const instance = new gcp.securesourcemanager.Instance("instance", {
* location: "us-central1",
* instanceId: "my-initial-instance",
* });
* const repository = new gcp.securesourcemanager.Repository("repository", {
* repositoryId: "my-initial-repository",
* instance: instance.name,
* location: instance.location,
* });
* const _default = new gcp.securesourcemanager.BranchRule("default", {
* branchRuleId: "my-initial-branchrule",
* location: repository.location,
* repositoryId: repository.repositoryId,
* includePattern: "test",
* minimumApprovalsCount: 2,
* minimumReviewsCount: 2,
* requireCommentsResolved: true,
* requireLinearHistory: true,
* requirePullRequest: true,
* disabled: false,
* allowStaleReviews: false,
* });
* ```
*
* ## Import
*
* BranchRule can be imported using any of these accepted formats:
*
* * `projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/branchRules/{{branch_rule_id}}`
*
* * `{{project}}/{{location}}/{{repository_id}}/{{branch_rule_id}}`
*
* * `{{location}}/{{repository_id}}/{{branch_rule_id}}`
*
* * `{{branch_rule_id}}`
*
* When using the `pulumi import` command, BranchRule can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:securesourcemanager/branchRule:BranchRule default projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/branchRules/{{branch_rule_id}}
* ```
*
* ```sh
* $ pulumi import gcp:securesourcemanager/branchRule:BranchRule default {{project}}/{{location}}/{{repository_id}}/{{branch_rule_id}}
* ```
*
* ```sh
* $ pulumi import gcp:securesourcemanager/branchRule:BranchRule default {{location}}/{{repository_id}}/{{branch_rule_id}}
* ```
*
* ```sh
* $ pulumi import gcp:securesourcemanager/branchRule:BranchRule default {{branch_rule_id}}
* ```
*/
class BranchRule extends pulumi.CustomResource {
/**
* Get an existing BranchRule 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 BranchRule(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of BranchRule. 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'] === BranchRule.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["allowStaleReviews"] = state ? state.allowStaleReviews : undefined;
resourceInputs["branchRuleId"] = state ? state.branchRuleId : undefined;
resourceInputs["createTime"] = state ? state.createTime : undefined;
resourceInputs["disabled"] = state ? state.disabled : undefined;
resourceInputs["includePattern"] = state ? state.includePattern : undefined;
resourceInputs["location"] = state ? state.location : undefined;
resourceInputs["minimumApprovalsCount"] = state ? state.minimumApprovalsCount : undefined;
resourceInputs["minimumReviewsCount"] = state ? state.minimumReviewsCount : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["repositoryId"] = state ? state.repositoryId : undefined;
resourceInputs["requireCommentsResolved"] = state ? state.requireCommentsResolved : undefined;
resourceInputs["requireLinearHistory"] = state ? state.requireLinearHistory : undefined;
resourceInputs["requirePullRequest"] = state ? state.requirePullRequest : undefined;
resourceInputs["uid"] = state ? state.uid : undefined;
resourceInputs["updateTime"] = state ? state.updateTime : undefined;
}
else {
const args = argsOrState;
if ((!args || args.branchRuleId === undefined) && !opts.urn) {
throw new Error("Missing required property 'branchRuleId'");
}
if ((!args || args.includePattern === undefined) && !opts.urn) {
throw new Error("Missing required property 'includePattern'");
}
if ((!args || args.location === undefined) && !opts.urn) {
throw new Error("Missing required property 'location'");
}
if ((!args || args.repositoryId === undefined) && !opts.urn) {
throw new Error("Missing required property 'repositoryId'");
}
resourceInputs["allowStaleReviews"] = args ? args.allowStaleReviews : undefined;
resourceInputs["branchRuleId"] = args ? args.branchRuleId : undefined;
resourceInputs["disabled"] = args ? args.disabled : undefined;
resourceInputs["includePattern"] = args ? args.includePattern : undefined;
resourceInputs["location"] = args ? args.location : undefined;
resourceInputs["minimumApprovalsCount"] = args ? args.minimumApprovalsCount : undefined;
resourceInputs["minimumReviewsCount"] = args ? args.minimumReviewsCount : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["repositoryId"] = args ? args.repositoryId : undefined;
resourceInputs["requireCommentsResolved"] = args ? args.requireCommentsResolved : undefined;
resourceInputs["requireLinearHistory"] = args ? args.requireLinearHistory : undefined;
resourceInputs["requirePullRequest"] = args ? args.requirePullRequest : undefined;
resourceInputs["createTime"] = undefined /*out*/;
resourceInputs["name"] = undefined /*out*/;
resourceInputs["uid"] = undefined /*out*/;
resourceInputs["updateTime"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(BranchRule.__pulumiType, name, resourceInputs, opts);
}
}
exports.BranchRule = BranchRule;
/** @internal */
BranchRule.__pulumiType = 'gcp:securesourcemanager/branchRule:BranchRule';
//# sourceMappingURL=branchRule.js.map