UNPKG

@ctfer-io/pulumi-ctfd

Version:

The CTFd provider for Pulumi, to manage its resources as code.

166 lines 7.05 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! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChallengeDynamic = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("./utilities")); /** * CTFd is built around the Challenge resource, which contains all the attributes to define a part of the Capture The Flag event. * * This implementation has support of a more dynamic behavior for its scoring through time/solves thus is different from a standard challenge. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as ctfd from "@ctfer-io/pulumi-ctfd"; * import * as fs from "fs"; * * const http = new ctfd.ChallengeDynamic("http", { * category: "misc", * description: "...", * value: 500, * decay: 100, * minimum: 50, * state: "visible", * "function": "logarithmic", * topics: ["Misc"], * tags: [ * "misc", * "basic", * ], * }); * const httpFlag = new ctfd.Flag("httpFlag", { * challengeId: http.id, * content: "CTF{some_flag}", * }); * const httpHint1 = new ctfd.Hint("httpHint1", { * challengeId: http.id, * content: "Some super-helpful hint", * cost: 50, * }); * const httpHint2 = new ctfd.Hint("httpHint2", { * challengeId: http.id, * content: "Even more helpful hint !", * cost: 50, * requirements: [httpHint1.id], * }); * const httpFile = new ctfd.File("httpFile", { * challengeId: http.id, * contentb64: fs.readFileSync(".../image.png", { encoding: "base64" }), * }); * ``` */ class ChallengeDynamic extends pulumi.CustomResource { /** * Get an existing ChallengeDynamic 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 ChallengeDynamic(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'ctfd:index/challengeDynamic:ChallengeDynamic'; /** * Returns true if the given object is an instance of ChallengeDynamic. 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'] === ChallengeDynamic.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["attribution"] = state?.attribution; resourceInputs["category"] = state?.category; resourceInputs["connectionInfo"] = state?.connectionInfo; resourceInputs["decay"] = state?.decay; resourceInputs["description"] = state?.description; resourceInputs["function"] = state?.function; resourceInputs["logic"] = state?.logic; resourceInputs["maxAttempts"] = state?.maxAttempts; resourceInputs["minimum"] = state?.minimum; resourceInputs["name"] = state?.name; resourceInputs["next"] = state?.next; resourceInputs["position"] = state?.position; resourceInputs["requirements"] = state?.requirements; resourceInputs["state"] = state?.state; resourceInputs["tags"] = state?.tags; resourceInputs["topics"] = state?.topics; resourceInputs["value"] = state?.value; } else { const args = argsOrState; if (args?.category === undefined && !opts.urn) { throw new Error("Missing required property 'category'"); } if (args?.decay === undefined && !opts.urn) { throw new Error("Missing required property 'decay'"); } if (args?.description === undefined && !opts.urn) { throw new Error("Missing required property 'description'"); } if (args?.minimum === undefined && !opts.urn) { throw new Error("Missing required property 'minimum'"); } if (args?.value === undefined && !opts.urn) { throw new Error("Missing required property 'value'"); } resourceInputs["attribution"] = args?.attribution; resourceInputs["category"] = args?.category; resourceInputs["connectionInfo"] = args?.connectionInfo; resourceInputs["decay"] = args?.decay; resourceInputs["description"] = args?.description; resourceInputs["function"] = args?.function; resourceInputs["logic"] = args?.logic; resourceInputs["maxAttempts"] = args?.maxAttempts; resourceInputs["minimum"] = args?.minimum; resourceInputs["name"] = args?.name; resourceInputs["next"] = args?.next; resourceInputs["position"] = args?.position; resourceInputs["requirements"] = args?.requirements; resourceInputs["state"] = args?.state; resourceInputs["tags"] = args?.tags; resourceInputs["topics"] = args?.topics; resourceInputs["value"] = args?.value; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(ChallengeDynamic.__pulumiType, name, resourceInputs, opts); } } exports.ChallengeDynamic = ChallengeDynamic; //# sourceMappingURL=challengeDynamic.js.map