Make the default for calls
This commit is contained in:
parent
ae13d6672c
commit
2ec1825a15
|
@ -36,8 +36,12 @@ export interface InvokeOptions {
|
||||||
version?: string;
|
version?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke this function asynchronously. If 'true' is passed in here, then an invoked function
|
* Invoke this data source function asynchronously. Defaults to `true` if unspecified.
|
||||||
* will only supply the `Promise<>` side of its result.
|
*
|
||||||
|
* When `true`, only the `Promise<>` side of the invoke result is present. Explicitly pass in
|
||||||
|
* `false` to get the non-Promise side of the result. Invoking data source functions
|
||||||
|
* synchronously is deprecated. The ability to do this will be removed at a later point in
|
||||||
|
* time.
|
||||||
*/
|
*/
|
||||||
async?: boolean;
|
async?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,11 +68,11 @@ const providerproto = require("../proto/provider_pb.js");
|
||||||
* synchronously.
|
* synchronously.
|
||||||
*/
|
*/
|
||||||
export function invoke(tok: string, props: Inputs, opts: InvokeOptions = {}): Promise<any> {
|
export function invoke(tok: string, props: Inputs, opts: InvokeOptions = {}): Promise<any> {
|
||||||
if (opts.async) {
|
if (opts.async !== false) {
|
||||||
// User specifically requested async invoking. Respect that.
|
|
||||||
return invokeAsync(tok, props, opts);
|
return invokeAsync(tok, props, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// User specifically requested sync invoking. Respect that.
|
||||||
const config = new Config("pulumi");
|
const config = new Config("pulumi");
|
||||||
const noSyncCalls = config.getBoolean("noSyncCalls");
|
const noSyncCalls = config.getBoolean("noSyncCalls");
|
||||||
if (noSyncCalls) {
|
if (noSyncCalls) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ let args = {
|
||||||
urn: "some-urn",
|
urn: "some-urn",
|
||||||
};
|
};
|
||||||
|
|
||||||
let result1 = pulumi.runtime.invoke("invoke:index:echo", args);
|
let result1 = pulumi.runtime.invoke("invoke:index:echo", args, { async: false });
|
||||||
|
|
||||||
// When invoking synchronously: Ensure the properties come back synchronously and are present on the
|
// When invoking synchronously: Ensure the properties come back synchronously and are present on the
|
||||||
// result.
|
// result.
|
||||||
|
@ -25,7 +25,7 @@ result1.then(v => {
|
||||||
assert.deepEqual(v, args);
|
assert.deepEqual(v, args);
|
||||||
});
|
});
|
||||||
|
|
||||||
let result2 = pulumi.runtime.invoke("invoke:index:echo", args, { async: true });
|
let result2 = pulumi.runtime.invoke("invoke:index:echo", args);
|
||||||
|
|
||||||
// When invoking asynchronously: Ensure the properties are *not* present on the result.
|
// When invoking asynchronously: Ensure the properties are *not* present on the result.
|
||||||
for (const key in args) {
|
for (const key in args) {
|
||||||
|
|
|
@ -10,13 +10,13 @@ new MyResource("testResource", "0.19.1");
|
||||||
new MyResource("testResource2", "0.19.2");
|
new MyResource("testResource2", "0.19.2");
|
||||||
new MyResource("testResource3");
|
new MyResource("testResource3");
|
||||||
|
|
||||||
|
pulumi.runtime.invoke("invoke:index:doit", {}, { version: "0.19.1" }, { async: false });
|
||||||
|
pulumi.runtime.invoke("invoke:index:doit_v2", {}, { version: "0.19.2" }, { async: false });
|
||||||
|
pulumi.runtime.invoke("invoke:index:doit_noversion", {}, { async: false });
|
||||||
|
|
||||||
pulumi.runtime.invoke("invoke:index:doit", {}, { version: "0.19.1" });
|
pulumi.runtime.invoke("invoke:index:doit", {}, { version: "0.19.1" });
|
||||||
pulumi.runtime.invoke("invoke:index:doit_v2", {}, { version: "0.19.2" });
|
pulumi.runtime.invoke("invoke:index:doit_v2", {}, { version: "0.19.2" });
|
||||||
pulumi.runtime.invoke("invoke:index:doit_noversion", {});
|
pulumi.runtime.invoke("invoke:index:doit_noversion", {});
|
||||||
|
|
||||||
pulumi.runtime.invoke("invoke:index:doit", {}, { version: "0.19.1" }, { async: true });
|
|
||||||
pulumi.runtime.invoke("invoke:index:doit_v2", {}, { version: "0.19.2" }, { async: true });
|
|
||||||
pulumi.runtime.invoke("invoke:index:doit_noversion", {}, { async: true });
|
|
||||||
|
|
||||||
new pulumi.CustomResource("test:index:ReadResource", "foo", {}, { id: "readme", version: "0.20.0" });
|
new pulumi.CustomResource("test:index:ReadResource", "foo", {}, { id: "readme", version: "0.20.0" });
|
||||||
new pulumi.CustomResource("test:index:ReadResource", "foo_noversion", {}, { id: "readme" });
|
new pulumi.CustomResource("test:index:ReadResource", "foo_noversion", {}, { id: "readme" });
|
||||||
|
|
|
@ -23,18 +23,18 @@ let args = {
|
||||||
if (semver.lt(process.version, "12.11.0")) {
|
if (semver.lt(process.version, "12.11.0")) {
|
||||||
// These tests hang on runtimes later than 12.10.x due to their use of deasync.
|
// These tests hang on runtimes later than 12.10.x due to their use of deasync.
|
||||||
|
|
||||||
let result1 = pulumi.runtime.invoke("test:index:echo", args, { provider });
|
let result1 = pulumi.runtime.invoke("test:index:echo", args, { provider, async: false });
|
||||||
for (const key in args) {
|
for (const key in args) {
|
||||||
assert.deepEqual(result1[key], args[key]);
|
assert.deepEqual(result1[key], args[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result2 = pulumi.runtime.invoke("test:index:echo", args, { provider });
|
let result2 = pulumi.runtime.invoke("test:index:echo", args, { provider, async: false });
|
||||||
result2.then((v) => {
|
result2.then((v) => {
|
||||||
assert.deepEqual(v, args);
|
assert.deepEqual(v, args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let result3 = pulumi.runtime.invoke("test:index:echo", args, { provider, async: true });
|
let result3 = pulumi.runtime.invoke("test:index:echo", args, { provider });
|
||||||
result3.then((v) => {
|
result3.then((v) => {
|
||||||
assert.deepEqual(v, args);
|
assert.deepEqual(v, args);
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,18 +30,18 @@ let args = {
|
||||||
if (semver.lt(process.version, "12.11.0")) {
|
if (semver.lt(process.version, "12.11.0")) {
|
||||||
// These tests hang on runtimes later than 12.10.x due to their use of deasync.
|
// These tests hang on runtimes later than 12.10.x due to their use of deasync.
|
||||||
|
|
||||||
let result1 = pulumi.runtime.invoke("test:index:echo", args, { parent });
|
let result1 = pulumi.runtime.invoke("test:index:echo", args, { parent, async: false });
|
||||||
for (const key in args) {
|
for (const key in args) {
|
||||||
assert.deepEqual(result1[key], args[key]);
|
assert.deepEqual(result1[key], args[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result2 = pulumi.runtime.invoke("test:index:echo", args, { parent });
|
let result2 = pulumi.runtime.invoke("test:index:echo", args, { parent, async: false });
|
||||||
result2.then((v) => {
|
result2.then((v) => {
|
||||||
assert.deepEqual(v, args);
|
assert.deepEqual(v, args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let result3 = pulumi.runtime.invoke("test:index:echo", args, { parent, async: true });
|
let result3 = pulumi.runtime.invoke("test:index:echo", args, { parent });
|
||||||
result3.then((v) => {
|
result3.then((v) => {
|
||||||
assert.deepEqual(v, args);
|
assert.deepEqual(v, args);
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,17 +21,17 @@ let pulumi = require("../../../../../");
|
||||||
urn: "some-urn",
|
urn: "some-urn",
|
||||||
};
|
};
|
||||||
|
|
||||||
let result1 = pulumi.runtime.invoke("test:index:echo", args, { provider });
|
let result1 = pulumi.runtime.invoke("test:index:echo", args, { provider, async: false });
|
||||||
for (const key in args) {
|
for (const key in args) {
|
||||||
assert.deepEqual(result1[key], args[key]);
|
assert.deepEqual(result1[key], args[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result2 = pulumi.runtime.invoke("test:index:echo", args, { provider });
|
let result2 = pulumi.runtime.invoke("test:index:echo", args, { provider, async: false });
|
||||||
result2.then((v) => {
|
result2.then((v) => {
|
||||||
assert.deepEqual(v, args);
|
assert.deepEqual(v, args);
|
||||||
});
|
});
|
||||||
|
|
||||||
let result3 = pulumi.runtime.invoke("test:index:echo", args, { provider, async: true });
|
let result3 = pulumi.runtime.invoke("test:index:echo", args, { provider });
|
||||||
result3.then((v) => {
|
result3.then((v) => {
|
||||||
assert.deepEqual(v, args);
|
assert.deepEqual(v, args);
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,17 +29,17 @@ let pulumi = require("../../../../../");
|
||||||
urn: "some-urn",
|
urn: "some-urn",
|
||||||
};
|
};
|
||||||
|
|
||||||
let result1 = pulumi.runtime.invoke("test:index:echo", args, { parent });
|
let result1 = pulumi.runtime.invoke("test:index:echo", args, { parent, async: false });
|
||||||
for (const key in args) {
|
for (const key in args) {
|
||||||
assert.deepEqual(result1[key], args[key]);
|
assert.deepEqual(result1[key], args[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result2 = pulumi.runtime.invoke("test:index:echo", args, { parent });
|
let result2 = pulumi.runtime.invoke("test:index:echo", args, { parent, async: false });
|
||||||
result2.then((v) => {
|
result2.then((v) => {
|
||||||
assert.deepEqual(v, args);
|
assert.deepEqual(v, args);
|
||||||
});
|
});
|
||||||
|
|
||||||
let result3 = pulumi.runtime.invoke("test:index:echo", args, { parent, async: true });
|
let result3 = pulumi.runtime.invoke("test:index:echo", args, { parent });
|
||||||
result3.then((v) => {
|
result3.then((v) => {
|
||||||
assert.deepEqual(v, args);
|
assert.deepEqual(v, args);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue