UNPKG

@pulumi/awsx

Version:

[![Actions Status](https://github.com/pulumi/pulumi-awsx/workflows/master/badge.svg)](https://github.com/pulumi/pulumi-awsx/actions) [![Slack](http://www.pulumi.com/images/docs/badges/slack.svg)](https://slack.pulumi.com) [![NPM version](https://badge.fur

123 lines 4.38 kB
"use strict"; // *** WARNING: this file was generated by pulumi-gen-awsx. *** // *** 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 () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.getEnv = getEnv; exports.getEnvBoolean = getEnvBoolean; exports.getEnvNumber = getEnvNumber; exports.getVersion = getVersion; exports.resourceOptsDefaults = resourceOptsDefaults; exports.lazyLoad = lazyLoad; exports.callAsync = callAsync; const runtime = __importStar(require("@pulumi/pulumi/runtime")); function getEnv(...vars) { for (const v of vars) { const value = process.env[v]; if (value) { return value; } } return undefined; } function getEnvBoolean(...vars) { const s = getEnv(...vars); if (s !== undefined) { // NOTE: these values are taken from https://golang.org/src/strconv/atob.go?s=351:391#L1, which is what // Terraform uses internally when parsing boolean values. if (["1", "t", "T", "true", "TRUE", "True"].find(v => v === s) !== undefined) { return true; } if (["0", "f", "F", "false", "FALSE", "False"].find(v => v === s) !== undefined) { return false; } } return undefined; } function getEnvNumber(...vars) { const s = getEnv(...vars); if (s !== undefined) { const f = parseFloat(s); if (!isNaN(f)) { return f; } } return undefined; } function getVersion() { let version = require('./package.json').version; // Node allows for the version to be prefixed by a "v", while semver doesn't. // If there is a v, strip it off. if (version.indexOf('v') === 0) { version = version.slice(1); } return version; } /** @internal */ function resourceOptsDefaults() { return { version: getVersion() }; } /** @internal */ function lazyLoad(exports, props, loadModule) { for (let property of props) { Object.defineProperty(exports, property, { enumerable: true, get: function () { return loadModule()[property]; }, }); } } /** @internal */ async function callAsync(tok, props, res, opts) { const o = runtime.call(tok, props, res); const value = await o.promise(true /*withUnknowns*/); const isKnown = await o.isKnown; const isSecret = await o.isSecret; const problem = !isKnown ? "an unknown value" : isSecret ? "a secret value" : undefined; // Ingoring o.resources silently. They are typically non-empty, r.f() calls include r as a dependency. if (problem) { throw new Error(`Plain resource method "${tok}" incorrectly returned ${problem}. ` + "This is an error in the provider, please report this to the provider developer."); } // Extract a single property if requested. if (opts && opts.property) { return value[opts.property]; } return value; } //# sourceMappingURL=utilities.js.map