UNPKG

@pulumi/github

Version:

A Pulumi package for creating and managing github cloud resources.

132 lines 5.67 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.RepositoryEnvironmentDeploymentPolicy = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * This resource allows you to create and manage environment deployment branch policies for a GitHub repository. * * ## Example Usage * * Create a branch-based deployment policy: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as github from "@pulumi/github"; * * const current = github.getUser({ * username: "", * }); * const test = new github.Repository("test", {name: "tf-acc-test-%s"}); * const testRepositoryEnvironment = new github.RepositoryEnvironment("test", { * repository: test.name, * environment: "environment/test", * waitTimer: 10000, * reviewers: [{ * users: [current.then(current => current.id)], * }], * deploymentBranchPolicy: { * protectedBranches: false, * customBranchPolicies: true, * }, * }); * const testRepositoryEnvironmentDeploymentPolicy = new github.RepositoryEnvironmentDeploymentPolicy("test", { * repository: test.name, * environment: testRepositoryEnvironment.environment, * branchPattern: "releases/*", * }); * ``` * * Create a tag-based deployment policy: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as github from "@pulumi/github"; * * const current = github.getUser({ * username: "", * }); * const test = new github.Repository("test", {name: "tf-acc-test-%s"}); * const testRepositoryEnvironment = new github.RepositoryEnvironment("test", { * repository: test.name, * environment: "environment/test", * waitTimer: 10000, * reviewers: [{ * users: [current.then(current => current.id)], * }], * deploymentBranchPolicy: { * protectedBranches: false, * customBranchPolicies: true, * }, * }); * const testRepositoryEnvironmentDeploymentPolicy = new github.RepositoryEnvironmentDeploymentPolicy("test", { * repository: test.name, * environment: testRepositoryEnvironment.environment, * tagPattern: "v*", * }); * ``` * * ## Import * * GitHub Repository Environment Deployment Policy can be imported using an ID made up of `name` of the repository combined with the `environment` name of the environment with the `Id` of the deployment policy, separated by a `:` character, e.g. * * ```sh * $ pulumi import github:index/repositoryEnvironmentDeploymentPolicy:RepositoryEnvironmentDeploymentPolicy daily terraform:daily:123456 * ``` */ class RepositoryEnvironmentDeploymentPolicy extends pulumi.CustomResource { /** * Get an existing RepositoryEnvironmentDeploymentPolicy 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 RepositoryEnvironmentDeploymentPolicy(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of RepositoryEnvironmentDeploymentPolicy. 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'] === RepositoryEnvironmentDeploymentPolicy.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["branchPattern"] = state ? state.branchPattern : undefined; resourceInputs["environment"] = state ? state.environment : undefined; resourceInputs["repository"] = state ? state.repository : undefined; resourceInputs["tagPattern"] = state ? state.tagPattern : undefined; } else { const args = argsOrState; if ((!args || args.environment === undefined) && !opts.urn) { throw new Error("Missing required property 'environment'"); } if ((!args || args.repository === undefined) && !opts.urn) { throw new Error("Missing required property 'repository'"); } resourceInputs["branchPattern"] = args ? args.branchPattern : undefined; resourceInputs["environment"] = args ? args.environment : undefined; resourceInputs["repository"] = args ? args.repository : undefined; resourceInputs["tagPattern"] = args ? args.tagPattern : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(RepositoryEnvironmentDeploymentPolicy.__pulumiType, name, resourceInputs, opts); } } exports.RepositoryEnvironmentDeploymentPolicy = RepositoryEnvironmentDeploymentPolicy; /** @internal */ RepositoryEnvironmentDeploymentPolicy.__pulumiType = 'github:index/repositoryEnvironmentDeploymentPolicy:RepositoryEnvironmentDeploymentPolicy'; //# sourceMappingURL=repositoryEnvironmentDeploymentPolicy.js.map