@pulumi/github
Version:
A Pulumi package for creating and managing github cloud resources.
104 lines • 4.32 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.Branch = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* This resource allows you to create and manage branches within your repository.
*
* Additional constraints can be applied to ensure your branch is created from
* another branch or commit.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as github from "@pulumi/github";
*
* const development = new github.Branch("development", {
* repository: "example",
* branch: "development",
* });
* ```
*
* ## Import
*
* GitHub Branch can be imported using an ID made up of `repository:branch`, e.g.
*
* ```sh
* $ pulumi import github:index/branch:Branch terraform terraform:main
* ```
* Importing github branch into an instance object (when using a for each block to manage multiple branches)
*
* ```sh
* $ pulumi import github:index/branch:Branch terraform["terraform"] terraform:main
* ```
* Optionally, a source branch may be specified using an ID of `repository:branch:source_branch`.
* This is useful for importing branches that do not branch directly off main.
*
* ```sh
* $ pulumi import github:index/branch:Branch terraform terraform:feature-branch:dev
* ```
*/
class Branch extends pulumi.CustomResource {
/**
* Get an existing Branch 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 Branch(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Branch. 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'] === Branch.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["branch"] = state ? state.branch : undefined;
resourceInputs["etag"] = state ? state.etag : undefined;
resourceInputs["ref"] = state ? state.ref : undefined;
resourceInputs["repository"] = state ? state.repository : undefined;
resourceInputs["sha"] = state ? state.sha : undefined;
resourceInputs["sourceBranch"] = state ? state.sourceBranch : undefined;
resourceInputs["sourceSha"] = state ? state.sourceSha : 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["repository"] = args ? args.repository : undefined;
resourceInputs["sourceBranch"] = args ? args.sourceBranch : undefined;
resourceInputs["sourceSha"] = args ? args.sourceSha : undefined;
resourceInputs["etag"] = undefined /*out*/;
resourceInputs["ref"] = undefined /*out*/;
resourceInputs["sha"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Branch.__pulumiType, name, resourceInputs, opts);
}
}
exports.Branch = Branch;
/** @internal */
Branch.__pulumiType = 'github:index/branch:Branch';
//# sourceMappingURL=branch.js.map
;