@pulumi/pulumi
Advanced tools
Comparing version 0.11.0-dev-135-gb4a3a268 to 0.11.0-dev-140-gd58bc719
@@ -135,7 +135,4 @@ "use strict"; | ||
}); | ||
// If any config variables are present, parse and set them, so the subsequent accesses are fast. | ||
const envObject = runtime.getConfigEnv(); | ||
for (const key of Object.keys(envObject)) { | ||
runtime.setConfig(key, envObject[key]); | ||
} | ||
// Load configuration passed from the language plugin | ||
runtime.loadConfig(); | ||
// If there is a --project=p, and/or a --stack=s, use them in the options. | ||
@@ -142,0 +139,0 @@ const project = argv["project"]; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const errors_1 = require("./errors"); | ||
const log = require("./log"); | ||
const runtime = require("./runtime"); | ||
@@ -16,2 +17,11 @@ /** | ||
constructor(name) { | ||
// To ease migration of code that already does new Config("<package>:config"), treat this as if | ||
// just new Config("<package>") was called. | ||
if (name.endsWith(":config")) { | ||
const newName = name.replace(/:config$/, ""); | ||
log.warn("`:config` is no longer required at the end of configuration " + | ||
"bag names and support will be removed in a future version, please " + | ||
"use new Config(\"%s\") instead.", newName); | ||
name = newName; | ||
} | ||
this.name = name; | ||
@@ -18,0 +28,0 @@ } |
{ | ||
"name": "@pulumi/pulumi", | ||
"version": "0.11.0-dev-135-gb4a3a268", | ||
"version": "0.11.0-dev-140-gd58bc719", | ||
"description": "Pulumi's Node.js SDK", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/pulumi/pulumi/sdk/nodejs", |
/** | ||
* configEnvKey is the environment variable key for configuration that we will check in the event that a | ||
* configuration variable is missing. Explicit overrides take precedence. | ||
*/ | ||
export declare const configEnvKey = "PULUMI_CONFIG"; | ||
/** | ||
* setConfig sets a configuration variable. | ||
@@ -15,11 +10,4 @@ */ | ||
/** | ||
* getConfigEnvKey returns a scrubbed environment variable key, PULUMI_CONFIG_<k>, that can be used for | ||
* setting explicit varaibles. This is unlike PULUMI_CONFIG which is just a JSON-serialized bag. | ||
* loadConfig populates the runtime.config object based on configuration set in the environment. | ||
*/ | ||
export declare function getConfigEnvKey(key: string): string; | ||
/** | ||
* getConfigEnv returns the environment map that will be used for config checking when variables aren't set. | ||
*/ | ||
export declare function getConfigEnv(): { | ||
[key: string]: string; | ||
}; | ||
export declare function loadConfig(): void; |
@@ -5,6 +5,5 @@ "use strict"; | ||
/** | ||
* configEnvKey is the environment variable key for configuration that we will check in the event that a | ||
* configuration variable is missing. Explicit overrides take precedence. | ||
* configEnvKey is the environment variable key that the language plugin uses to set configuration values. | ||
*/ | ||
exports.configEnvKey = "PULUMI_CONFIG"; | ||
const configEnvKey = "PULUMI_CONFIG"; | ||
const config = {}; | ||
@@ -15,3 +14,3 @@ /** | ||
function setConfig(k, v) { | ||
config[k] = v; | ||
config[cleanKey(k)] = v; | ||
} | ||
@@ -27,12 +26,2 @@ exports.setConfig = setConfig; | ||
} | ||
// If there is a specific PULUMI_CONFIG_<k> variable, use it. | ||
const envKey = getConfigEnvKey(k); | ||
if (process.env.hasOwnProperty(envKey)) { | ||
return process.env[envKey]; | ||
} | ||
// If the config hasn't been set, but there is a process-wide PULUMI_CONFIG envvar, use it. | ||
const envObject = getConfigEnv(); | ||
if (envObject.hasOwnProperty(k)) { | ||
return envObject[k]; | ||
} | ||
return undefined; | ||
@@ -42,31 +31,27 @@ } | ||
/** | ||
* getConfigEnvKey returns a scrubbed environment variable key, PULUMI_CONFIG_<k>, that can be used for | ||
* setting explicit varaibles. This is unlike PULUMI_CONFIG which is just a JSON-serialized bag. | ||
* loadConfig populates the runtime.config object based on configuration set in the environment. | ||
*/ | ||
function getConfigEnvKey(key) { | ||
let envkey = ""; | ||
for (const c of key) { | ||
if (c === "_" || (c >= "A" && c <= "Z") || (c >= "0" && c <= "9")) { | ||
envkey += c; | ||
function loadConfig() { | ||
const envConfig = process.env.PULUMI_CONFIG; | ||
if (envConfig) { | ||
const envObject = JSON.parse(envConfig); | ||
for (const key of Object.keys(envObject)) { | ||
setConfig(key, envObject[key]); | ||
} | ||
else if (c >= "a" && c <= "z") { | ||
envkey += c.toUpperCase(); | ||
} | ||
else { | ||
envkey += "_"; | ||
} | ||
} | ||
return `${exports.configEnvKey}_${envkey}`; | ||
} | ||
exports.getConfigEnvKey = getConfigEnvKey; | ||
exports.loadConfig = loadConfig; | ||
/** | ||
* getConfigEnv returns the environment map that will be used for config checking when variables aren't set. | ||
* cleanKey takes a configuration key, and if it is of the form "<string>:config:<string>" removes the ":config:" | ||
* portion. Previously, our keys always had the string ":config:" in them, and we'd like to remove it. However, the | ||
* language host needs to continue to set it so we can be compatable with older versions of our packages. Once we | ||
* stop supporting older packages, we can change the language host to not add this :config: thing and remove this | ||
* function. | ||
*/ | ||
function getConfigEnv() { | ||
const envConfig = process.env.PULUMI_CONFIG; | ||
if (envConfig) { | ||
return JSON.parse(envConfig); | ||
function cleanKey(key) { | ||
const idx = key.indexOf(":"); | ||
if (idx > 0 && key.startsWith("config:", idx + 1)) { | ||
return key.substring(0, idx) + ":" + key.substring(idx + 1 + "config:".length); | ||
} | ||
return {}; | ||
return key; | ||
} | ||
exports.getConfigEnv = getConfigEnv; |
@@ -9,3 +9,3 @@ // Ensure that certain runtime settings are available. | ||
const config = new pulumi.Config("myBag:config"); | ||
const config = new pulumi.Config("myBag"); | ||
assert.equal(config.getNumber("A"), 42); | ||
@@ -17,1 +17,9 @@ assert.equal(config.requireNumber("A"), 42); | ||
// ensure the older format works as well | ||
const configOld = new pulumi.Config("myBag:config"); | ||
assert.equal(configOld.getNumber("A"), 42); | ||
assert.equal(configOld.requireNumber("A"), 42); | ||
assert.equal(configOld.get("bbbb"), "a string o' b's"); | ||
assert.equal(configOld.require("bbbb"), "a string o' b's"); | ||
assert.equal(configOld.get("missingC"), undefined); | ||
"use strict"; | ||
// Copyright 2016-2017, Pulumi Corporation. All rights reserved. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = "0.11.0-dev-135-gb4a3a268"; | ||
exports.version = "0.11.0-dev-140-gd58bc719"; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
537626
13886