UNPKG

@ctfer-io/pulumi-ctfd

Version:

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

139 lines 6.43 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.ChallengeDynamic = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = 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, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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 ? state.attribution : undefined; resourceInputs["category"] = state ? state.category : undefined; resourceInputs["connectionInfo"] = state ? state.connectionInfo : undefined; resourceInputs["decay"] = state ? state.decay : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["function"] = state ? state.function : undefined; resourceInputs["maxAttempts"] = state ? state.maxAttempts : undefined; resourceInputs["minimum"] = state ? state.minimum : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["next"] = state ? state.next : undefined; resourceInputs["requirements"] = state ? state.requirements : undefined; resourceInputs["state"] = state ? state.state : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["topics"] = state ? state.topics : undefined; resourceInputs["value"] = state ? state.value : undefined; } else { const args = argsOrState; if ((!args || args.category === undefined) && !opts.urn) { throw new Error("Missing required property 'category'"); } if ((!args || args.decay === undefined) && !opts.urn) { throw new Error("Missing required property 'decay'"); } if ((!args || args.description === undefined) && !opts.urn) { throw new Error("Missing required property 'description'"); } if ((!args || args.minimum === undefined) && !opts.urn) { throw new Error("Missing required property 'minimum'"); } if ((!args || args.value === undefined) && !opts.urn) { throw new Error("Missing required property 'value'"); } resourceInputs["attribution"] = args ? args.attribution : undefined; resourceInputs["category"] = args ? args.category : undefined; resourceInputs["connectionInfo"] = args ? args.connectionInfo : undefined; resourceInputs["decay"] = args ? args.decay : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["function"] = args ? args.function : undefined; resourceInputs["maxAttempts"] = args ? args.maxAttempts : undefined; resourceInputs["minimum"] = args ? args.minimum : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["next"] = args ? args.next : undefined; resourceInputs["requirements"] = args ? args.requirements : undefined; resourceInputs["state"] = args ? args.state : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["topics"] = args ? args.topics : undefined; resourceInputs["value"] = args ? args.value : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(ChallengeDynamic.__pulumiType, name, resourceInputs, opts); } } exports.ChallengeDynamic = ChallengeDynamic; /** @internal */ ChallengeDynamic.__pulumiType = 'ctfd:index/challengeDynamic:ChallengeDynamic'; //# sourceMappingURL=challengeDynamic.js.map