@pulumi/github
Version:
A Pulumi package for creating and managing github cloud resources.
146 lines • 6.51 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.RepositoryFile = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* This resource allows you to create and manage files within a
* GitHub repository.
*
* ## Example Usage
*
* ### Existing Branch
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as github from "@pulumi/github";
*
* const foo = new github.Repository("foo", {
* name: "tf-acc-test-%s",
* autoInit: true,
* });
* const fooRepositoryFile = new github.RepositoryFile("foo", {
* repository: foo.name,
* branch: "main",
* file: ".gitignore",
* content: "**/*.tfstate",
* commitMessage: "Managed by Pulumi",
* commitAuthor: "Terraform User",
* commitEmail: "terraform@example.com",
* overwriteOnCreate: true,
* });
* ```
*
* ### Auto Created Branch
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as github from "@pulumi/github";
*
* const foo = new github.Repository("foo", {
* name: "tf-acc-test-%s",
* autoInit: true,
* });
* const fooRepositoryFile = new github.RepositoryFile("foo", {
* repository: foo.name,
* branch: "does/not/exist",
* file: ".gitignore",
* content: "**/*.tfstate",
* commitMessage: "Managed by Pulumi",
* commitAuthor: "Terraform User",
* commitEmail: "terraform@example.com",
* overwriteOnCreate: true,
* autocreateBranch: true,
* });
* ```
*
* ## Import
*
* Repository files can be imported using a combination of the `repo` and `file`, e.g.
*
* ```sh
* $ pulumi import github:index/repositoryFile:RepositoryFile gitignore example/.gitignore
* ```
* To import a file from a branch other than the default branch, append `:` and the branch name, e.g.
*
* ```sh
* $ pulumi import github:index/repositoryFile:RepositoryFile gitignore example/.gitignore:dev
* ```
*/
class RepositoryFile extends pulumi.CustomResource {
/**
* Get an existing RepositoryFile 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 RepositoryFile(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of RepositoryFile. 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'] === RepositoryFile.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["autocreateBranch"] = state ? state.autocreateBranch : undefined;
resourceInputs["autocreateBranchSourceBranch"] = state ? state.autocreateBranchSourceBranch : undefined;
resourceInputs["autocreateBranchSourceSha"] = state ? state.autocreateBranchSourceSha : undefined;
resourceInputs["branch"] = state ? state.branch : undefined;
resourceInputs["commitAuthor"] = state ? state.commitAuthor : undefined;
resourceInputs["commitEmail"] = state ? state.commitEmail : undefined;
resourceInputs["commitMessage"] = state ? state.commitMessage : undefined;
resourceInputs["commitSha"] = state ? state.commitSha : undefined;
resourceInputs["content"] = state ? state.content : undefined;
resourceInputs["file"] = state ? state.file : undefined;
resourceInputs["overwriteOnCreate"] = state ? state.overwriteOnCreate : undefined;
resourceInputs["ref"] = state ? state.ref : undefined;
resourceInputs["repository"] = state ? state.repository : undefined;
resourceInputs["sha"] = state ? state.sha : undefined;
}
else {
const args = argsOrState;
if ((!args || args.content === undefined) && !opts.urn) {
throw new Error("Missing required property 'content'");
}
if ((!args || args.file === undefined) && !opts.urn) {
throw new Error("Missing required property 'file'");
}
if ((!args || args.repository === undefined) && !opts.urn) {
throw new Error("Missing required property 'repository'");
}
resourceInputs["autocreateBranch"] = args ? args.autocreateBranch : undefined;
resourceInputs["autocreateBranchSourceBranch"] = args ? args.autocreateBranchSourceBranch : undefined;
resourceInputs["autocreateBranchSourceSha"] = args ? args.autocreateBranchSourceSha : undefined;
resourceInputs["branch"] = args ? args.branch : undefined;
resourceInputs["commitAuthor"] = args ? args.commitAuthor : undefined;
resourceInputs["commitEmail"] = args ? args.commitEmail : undefined;
resourceInputs["commitMessage"] = args ? args.commitMessage : undefined;
resourceInputs["content"] = args ? args.content : undefined;
resourceInputs["file"] = args ? args.file : undefined;
resourceInputs["overwriteOnCreate"] = args ? args.overwriteOnCreate : undefined;
resourceInputs["repository"] = args ? args.repository : undefined;
resourceInputs["commitSha"] = undefined /*out*/;
resourceInputs["ref"] = undefined /*out*/;
resourceInputs["sha"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(RepositoryFile.__pulumiType, name, resourceInputs, opts);
}
}
exports.RepositoryFile = RepositoryFile;
/** @internal */
RepositoryFile.__pulumiType = 'github:index/repositoryFile:RepositoryFile';
//# sourceMappingURL=repositoryFile.js.map
;