@pulumi/github
Version:
A Pulumi package for creating and managing github cloud resources.
117 lines • 4.39 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.BranchDefault = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Provides a GitHub branch default resource.
*
* This resource allows you to set the default branch for a given repository.
*
* Note that use of this resource is incompatible with the `defaultBranch` option of the `github.Repository` resource. Using both will result in plans always showing a diff.
*
* ## Example Usage
*
* Basic usage:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as github from "@pulumi/github";
*
* const example = new github.Repository("example", {
* name: "example",
* description: "My awesome codebase",
* autoInit: true,
* });
* const development = new github.Branch("development", {
* repository: example.name,
* branch: "development",
* });
* const _default = new github.BranchDefault("default", {
* repository: example.name,
* branch: development.branch,
* });
* ```
*
* Renaming to a branch that doesn't exist:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as github from "@pulumi/github";
*
* const example = new github.Repository("example", {
* name: "example",
* description: "My awesome codebase",
* autoInit: true,
* });
* const _default = new github.BranchDefault("default", {
* repository: example.name,
* branch: "development",
* rename: true,
* });
* ```
*
* ## Import
*
* GitHub Branch Defaults can be imported using an ID made up of `repository`, e.g.
*
* ```sh
* $ pulumi import github:index/branchDefault:BranchDefault branch_default my-repo
* ```
*/
class BranchDefault extends pulumi.CustomResource {
/**
* Get an existing BranchDefault 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 BranchDefault(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of BranchDefault. 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'] === BranchDefault.__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["rename"] = state ? state.rename : undefined;
resourceInputs["repository"] = state ? state.repository : 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["rename"] = args ? args.rename : undefined;
resourceInputs["repository"] = args ? args.repository : undefined;
resourceInputs["etag"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(BranchDefault.__pulumiType, name, resourceInputs, opts);
}
}
exports.BranchDefault = BranchDefault;
/** @internal */
BranchDefault.__pulumiType = 'github:index/branchDefault:BranchDefault';
//# sourceMappingURL=branchDefault.js.map
;