@pulumi/pulumi 3.163.0-alpha.xdc88586 → 3.163.0-alpha.xe7c1e4f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/automation/cmd.js +92 -111
- package/automation/cmd.js.map +1 -1
- package/automation/localWorkspace.js +383 -476
- package/automation/localWorkspace.js.map +1 -1
- package/automation/remoteWorkspace.js +38 -55
- package/automation/remoteWorkspace.js.map +1 -1
- package/automation/server.js +6 -16
- package/automation/server.js.map +1 -1
- package/automation/stack.js +537 -608
- package/automation/stack.js.map +1 -1
- package/cmd/dynamic-provider/index.js +204 -235
- package/cmd/dynamic-provider/index.js.map +1 -1
- package/cmd/run/error.js +3 -3
- package/cmd/run/error.js.map +1 -1
- package/cmd/run/run.js +322 -336
- package/cmd/run/run.js.map +1 -1
- package/cmd/run/tracing.js +1 -2
- package/cmd/run/tracing.js.map +1 -1
- package/cmd/run-plugin/run.js +13 -17
- package/cmd/run-plugin/run.js.map +1 -1
- package/cmd/run-policy-pack/run.js +12 -16
- package/cmd/run-policy-pack/run.js.map +1 -1
- package/output.js +61 -78
- package/output.js.map +1 -1
- package/package.json +1 -1
- package/provider/experimental/analyzer.js +43 -46
- package/provider/experimental/analyzer.js.map +1 -1
- package/provider/experimental/provider.js +22 -36
- package/provider/experimental/provider.js.map +1 -1
- package/provider/server.js +359 -397
- package/provider/server.js.map +1 -1
- package/resource.js +29 -41
- package/resource.js.map +1 -1
- package/runtime/asyncIterableUtil.js +6 -17
- package/runtime/asyncIterableUtil.js.map +1 -1
- package/runtime/callbacks.js +254 -269
- package/runtime/callbacks.js.map +1 -1
- package/runtime/closure/codePaths.js +117 -135
- package/runtime/closure/codePaths.js.map +1 -1
- package/runtime/closure/createClosure.js +807 -871
- package/runtime/closure/createClosure.js.map +1 -1
- package/runtime/closure/parseFunction.js +2 -3
- package/runtime/closure/parseFunction.js.map +1 -1
- package/runtime/closure/serializeClosure.js +17 -30
- package/runtime/closure/serializeClosure.js.map +1 -1
- package/runtime/closure/v8.js +166 -190
- package/runtime/closure/v8.js.map +1 -1
- package/runtime/closure/v8Hooks.js +19 -34
- package/runtime/closure/v8Hooks.js.map +1 -1
- package/runtime/dependsOn.js +61 -80
- package/runtime/dependsOn.js.map +1 -1
- package/runtime/invoke.js +155 -170
- package/runtime/invoke.js.map +1 -1
- package/runtime/mocks.js +77 -96
- package/runtime/mocks.js.map +1 -1
- package/runtime/resource.js +238 -252
- package/runtime/resource.js.map +1 -1
- package/runtime/rpc.js +193 -215
- package/runtime/rpc.js.map +1 -1
- package/runtime/settings.js +70 -87
- package/runtime/settings.js.map +1 -1
- package/runtime/stack.js +111 -131
- package/runtime/stack.js.map +1 -1
- package/stackReference.js +39 -58
- package/stackReference.js.map +1 -1
- package/tsutils.js +1 -2
- package/tsutils.js.map +1 -1
- package/utils.js +2 -3
- package/utils.js.map +1 -1
- package/version.js +1 -1
package/runtime/dependsOn.js
CHANGED
|
@@ -12,15 +12,6 @@
|
|
|
12
12
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
16
|
const output_1 = require("../output");
|
|
26
17
|
const resource_1 = require("../resource");
|
|
@@ -29,36 +20,34 @@ const resource_1 = require("../resource");
|
|
|
29
20
|
*
|
|
30
21
|
* @internal
|
|
31
22
|
*/
|
|
32
|
-
function gatherExplicitDependencies(dependsOn) {
|
|
33
|
-
|
|
34
|
-
if (dependsOn) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
dos.push(...(yield gatherExplicitDependencies(d)));
|
|
39
|
-
}
|
|
40
|
-
return dos;
|
|
41
|
-
}
|
|
42
|
-
else if (dependsOn instanceof Promise) {
|
|
43
|
-
return gatherExplicitDependencies(yield dependsOn);
|
|
23
|
+
async function gatherExplicitDependencies(dependsOn) {
|
|
24
|
+
if (dependsOn) {
|
|
25
|
+
if (Array.isArray(dependsOn)) {
|
|
26
|
+
const dos = [];
|
|
27
|
+
for (const d of dependsOn) {
|
|
28
|
+
dos.push(...(await gatherExplicitDependencies(d)));
|
|
44
29
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
30
|
+
return dos;
|
|
31
|
+
}
|
|
32
|
+
else if (dependsOn instanceof Promise) {
|
|
33
|
+
return gatherExplicitDependencies(await dependsOn);
|
|
34
|
+
}
|
|
35
|
+
else if (output_1.Output.isInstance(dependsOn)) {
|
|
36
|
+
// Recursively gather dependencies, await the promise, and append the output's dependencies.
|
|
37
|
+
const dos = dependsOn.apply((v) => gatherExplicitDependencies(v));
|
|
38
|
+
const urns = await dos.promise();
|
|
39
|
+
const dosResources = await output_1.getAllResources(dos);
|
|
40
|
+
const implicits = await gatherExplicitDependencies([...dosResources]);
|
|
41
|
+
return (urns ?? []).concat(implicits);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
if (!resource_1.Resource.isInstance(dependsOn)) {
|
|
45
|
+
throw new Error("'dependsOn' was passed a value that was not a Resource.");
|
|
58
46
|
}
|
|
47
|
+
return [dependsOn];
|
|
59
48
|
}
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
}
|
|
50
|
+
return [];
|
|
62
51
|
}
|
|
63
52
|
exports.gatherExplicitDependencies = gatherExplicitDependencies;
|
|
64
53
|
/**
|
|
@@ -93,13 +82,11 @@ exports.gatherExplicitDependencies = gatherExplicitDependencies;
|
|
|
93
82
|
*
|
|
94
83
|
* @internal
|
|
95
84
|
*/
|
|
96
|
-
function getAllTransitivelyReferencedResources(resources, exclude) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return transitivelyReachableCustomResources;
|
|
102
|
-
});
|
|
85
|
+
async function getAllTransitivelyReferencedResources(resources, exclude) {
|
|
86
|
+
const transitivelyReachableResources = await getTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude);
|
|
87
|
+
// Then we filter to only include Custom and Remote resources.
|
|
88
|
+
const transitivelyReachableCustomResources = [...transitivelyReachableResources].filter((r) => (resource_1.CustomResource.isInstance(r) || r.__remote) && !exclude.has(r));
|
|
89
|
+
return transitivelyReachableCustomResources;
|
|
103
90
|
}
|
|
104
91
|
exports.getAllTransitivelyReferencedResources = getAllTransitivelyReferencedResources;
|
|
105
92
|
/**
|
|
@@ -108,13 +95,11 @@ exports.getAllTransitivelyReferencedResources = getAllTransitivelyReferencedReso
|
|
|
108
95
|
*
|
|
109
96
|
* @internal
|
|
110
97
|
*/
|
|
111
|
-
function getAllTransitivelyReferencedResourceURNs(resources, exclude) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return new Set(urns);
|
|
117
|
-
});
|
|
98
|
+
async function getAllTransitivelyReferencedResourceURNs(resources, exclude) {
|
|
99
|
+
const transitivelyReachableCustomResources = await getAllTransitivelyReferencedResources(resources, exclude);
|
|
100
|
+
const promises = transitivelyReachableCustomResources.map((r) => r.urn.promise());
|
|
101
|
+
const urns = await Promise.all(promises);
|
|
102
|
+
return new Set(urns);
|
|
118
103
|
}
|
|
119
104
|
exports.getAllTransitivelyReferencedResourceURNs = getAllTransitivelyReferencedResourceURNs;
|
|
120
105
|
/**
|
|
@@ -122,40 +107,36 @@ exports.getAllTransitivelyReferencedResourceURNs = getAllTransitivelyReferencedR
|
|
|
122
107
|
* reachable from {@link Resource.__childResources} through any **component**
|
|
123
108
|
* resources we encounter.
|
|
124
109
|
*/
|
|
125
|
-
function getTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return result;
|
|
131
|
-
});
|
|
110
|
+
async function getTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude) {
|
|
111
|
+
// Recursively walk the dependent resources through their children, adding them to the result set.
|
|
112
|
+
const result = new Set();
|
|
113
|
+
await addTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude, result);
|
|
114
|
+
return result;
|
|
132
115
|
}
|
|
133
|
-
function addTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude, result) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
// This await is safe even if __isConstructed is undefined. Ensure that the
|
|
148
|
-
// resource has completely finished construction. That way all parent/child
|
|
149
|
-
// relationships will have been setup.
|
|
150
|
-
promises.push(resource.__data.then(() => {
|
|
151
|
-
const children = resource.__childResources;
|
|
152
|
-
return addTransitivelyReferencedChildResourcesOfComponentResources(children, exclude, result);
|
|
153
|
-
}));
|
|
116
|
+
async function addTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude, result) {
|
|
117
|
+
// We can collect the resources out of the loop
|
|
118
|
+
const promises = [];
|
|
119
|
+
if (resources) {
|
|
120
|
+
for (const resource of resources) {
|
|
121
|
+
if (!result.has(resource)) {
|
|
122
|
+
result.add(resource);
|
|
123
|
+
if (resource_1.ComponentResource.isInstance(resource)) {
|
|
124
|
+
// Skip including children of a resource in the excluded set to avoid depending on
|
|
125
|
+
// children that haven't been registered yet.
|
|
126
|
+
if (exclude.has(resource)) {
|
|
127
|
+
continue;
|
|
154
128
|
}
|
|
129
|
+
// This await is safe even if __isConstructed is undefined. Ensure that the
|
|
130
|
+
// resource has completely finished construction. That way all parent/child
|
|
131
|
+
// relationships will have been setup.
|
|
132
|
+
promises.push(resource.__data.then(() => {
|
|
133
|
+
const children = resource.__childResources;
|
|
134
|
+
return addTransitivelyReferencedChildResourcesOfComponentResources(children, exclude, result);
|
|
135
|
+
}));
|
|
155
136
|
}
|
|
156
137
|
}
|
|
157
138
|
}
|
|
158
|
-
|
|
159
|
-
|
|
139
|
+
}
|
|
140
|
+
await Promise.all(promises);
|
|
160
141
|
}
|
|
161
142
|
//# sourceMappingURL=dependsOn.js.map
|
package/runtime/dependsOn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependsOn.js","sourceRoot":"","sources":["../../runtime/dependsOn.ts"],"names":[],"mappings":";AAAA,2CAA2C;AAC3C,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC
|
|
1
|
+
{"version":3,"file":"dependsOn.js","sourceRoot":"","sources":["../../runtime/dependsOn.ts"],"names":[],"mappings":";AAAA,2CAA2C;AAC3C,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,sCAA2D;AAC3D,0CAA0E;AAE1E;;;;GAIG;AACI,KAAK,UAAU,0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QAAQ,CAAC,EAAE;gBACvB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAErB,IAAI,4BAAiB,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;oBACxC,kFAAkF;oBAClF,6CAA6C;oBAC7C,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;wBACvB,SAAS;qBACZ;oBAED,2EAA2E;oBAC3E,4EAA4E;oBAC5E,sCAAsC;oBACtC,QAAQ,CAAC,IAAI,CACT,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;wBACtB,MAAM,QAAQ,GAAG,QAAQ,CAAC,gBAAgB,CAAC;wBAC3C,OAAO,2DAA2D,CAC9D,QAAQ,EACR,OAAO,EACP,MAAM,CACT,CAAC;oBACN,CAAC,CAAC,CACL,CAAC;iBACL;aACJ;SACJ;KACJ;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC"}
|
package/runtime/invoke.js
CHANGED
|
@@ -12,15 +12,6 @@
|
|
|
12
12
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
15
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
16
|
if (mod && mod.__esModule) return mod;
|
|
26
17
|
var result = {};
|
|
@@ -79,7 +70,7 @@ const resourceproto = __importStar(require("../proto/resource_pb"));
|
|
|
79
70
|
* to operate synchronously.
|
|
80
71
|
*/
|
|
81
72
|
function invoke(tok, props, opts = {}, packageRef) {
|
|
82
|
-
const optsCopy =
|
|
73
|
+
const optsCopy = { ...opts };
|
|
83
74
|
if ("dependsOn" in optsCopy) {
|
|
84
75
|
// DependsOn is only allowed for invokeOutput.
|
|
85
76
|
//@ts-ignore
|
|
@@ -149,143 +140,139 @@ function invokeSingleOutput(tok, props, opts = {}, packageRef) {
|
|
|
149
140
|
return output;
|
|
150
141
|
}
|
|
151
142
|
exports.invokeSingleOutput = invokeSingleOutput;
|
|
152
|
-
function invokeAsync(tok, props, opts, packageRef, checkDependencies) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
for (const
|
|
186
|
-
|
|
187
|
-
resourcesToWaitFor.add(value);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
// The expanded set of dependencies, including children of components.
|
|
191
|
-
const expandedDeps = yield dependsOn_1.getAllTransitivelyReferencedResources(resourcesToWaitFor, new Set());
|
|
192
|
-
// Ensure that all resource IDs are known before proceeding.
|
|
193
|
-
for (const dep of expandedDeps.values()) {
|
|
194
|
-
// DependencyResources inherit from CustomResource, but they don't set the id. Skip them.
|
|
195
|
-
if (resource_1.CustomResource.isInstance(dep) && dep.id) {
|
|
196
|
-
const known = yield dep.id.isKnown;
|
|
197
|
-
if (!known) {
|
|
198
|
-
return {
|
|
199
|
-
result: {},
|
|
200
|
-
isKnown: false,
|
|
201
|
-
containsSecrets: false,
|
|
202
|
-
dependencies: [],
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
}
|
|
143
|
+
async function invokeAsync(tok, props, opts, packageRef, checkDependencies) {
|
|
144
|
+
const label = `Invoking function: tok=${tok} asynchronously`;
|
|
145
|
+
log.debug(label + (settings_1.excessiveDebugOutput ? `, props=${JSON.stringify(props)}` : ``));
|
|
146
|
+
await settings_1.awaitStackRegistrations();
|
|
147
|
+
// Wait for all values to be available, and then perform the RPC.
|
|
148
|
+
const done = settings_1.rpcKeepAlive();
|
|
149
|
+
try {
|
|
150
|
+
// The direct dependencies of the invoke call from the dependsOn option.
|
|
151
|
+
const dependsOnDeps = await dependsOn_1.gatherExplicitDependencies(opts.dependsOn);
|
|
152
|
+
// The dependencies of the inputs to the invoke call.
|
|
153
|
+
const [serialized, deps] = await rpc_1.serializePropertiesReturnDeps(`invoke:${tok}`, props);
|
|
154
|
+
if (rpc_1.containsUnknownValues(serialized)) {
|
|
155
|
+
// if any of the input properties are unknown,
|
|
156
|
+
// make sure the entire response is marked as unknown
|
|
157
|
+
return {
|
|
158
|
+
result: {},
|
|
159
|
+
isKnown: false,
|
|
160
|
+
containsSecrets: false,
|
|
161
|
+
dependencies: [],
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
// Only check the resource dependencies for output form invokes. For
|
|
165
|
+
// plain invokes, we do not want to check the dependencies. Technically,
|
|
166
|
+
// these should only receive plain arguments, but this is not strictly
|
|
167
|
+
// enforced, and in practice people pass in outputs. This happens to
|
|
168
|
+
// work because we serialize the arguments.
|
|
169
|
+
if (checkDependencies) {
|
|
170
|
+
// If we depend on any CustomResources, we need to ensure that their
|
|
171
|
+
// ID is known before proceeding. If it is not known, we will return
|
|
172
|
+
// an unknown result.
|
|
173
|
+
const resourcesToWaitFor = new Set(dependsOnDeps);
|
|
174
|
+
// Add the dependencies from the inputs to the set of resources to wait for.
|
|
175
|
+
for (const resourceDeps of deps.values()) {
|
|
176
|
+
for (const value of resourceDeps.values()) {
|
|
177
|
+
resourcesToWaitFor.add(value);
|
|
206
178
|
}
|
|
207
179
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
settings_1.terminateRpcs();
|
|
223
|
-
err.message = "Resource monitor is terminating";
|
|
224
|
-
innerReject(err);
|
|
225
|
-
return;
|
|
180
|
+
// The expanded set of dependencies, including children of components.
|
|
181
|
+
const expandedDeps = await dependsOn_1.getAllTransitivelyReferencedResources(resourcesToWaitFor, new Set());
|
|
182
|
+
// Ensure that all resource IDs are known before proceeding.
|
|
183
|
+
for (const dep of expandedDeps.values()) {
|
|
184
|
+
// DependencyResources inherit from CustomResource, but they don't set the id. Skip them.
|
|
185
|
+
if (resource_1.CustomResource.isInstance(dep) && dep.id) {
|
|
186
|
+
const known = await dep.id.isKnown;
|
|
187
|
+
if (!known) {
|
|
188
|
+
return {
|
|
189
|
+
result: {},
|
|
190
|
+
isKnown: false,
|
|
191
|
+
containsSecrets: false,
|
|
192
|
+
dependencies: [],
|
|
193
|
+
};
|
|
226
194
|
}
|
|
227
|
-
// If the RPC failed, rethrow the error with a native exception and the message that
|
|
228
|
-
// the engine provided - it's suitable for user presentation.
|
|
229
|
-
innerReject(new Error(err.details));
|
|
230
195
|
}
|
|
231
|
-
|
|
232
|
-
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
log.debug(`Invoke RPC prepared: tok=${tok}` + settings_1.excessiveDebugOutput ? `, obj=${JSON.stringify(serialized)}` : ``);
|
|
199
|
+
// Fetch the monitor and make an RPC request.
|
|
200
|
+
const monitor = settings_1.getMonitor();
|
|
201
|
+
const provider = await resource_1.ProviderResource.register(getProvider(tok, opts));
|
|
202
|
+
// keep track of the the secretness of the inputs
|
|
203
|
+
// if any of the inputs are secret, the invoke response should be marked as secret
|
|
204
|
+
const [plainInputs, inputsContainSecrets] = rpc_1.unwrapSecretValues(serialized);
|
|
205
|
+
const req = await createInvokeRequest(tok, plainInputs, provider, opts, packageRef);
|
|
206
|
+
const resp = await debuggable_1.debuggablePromise(new Promise((innerResolve, innerReject) => monitor.invoke(req, (err, innerResponse) => {
|
|
207
|
+
log.debug(`Invoke RPC finished: tok=${tok}; err: ${err}, resp: ${innerResponse}`);
|
|
208
|
+
if (err) {
|
|
209
|
+
// If the monitor is unavailable, it is in the process of shutting down or has already
|
|
210
|
+
// shut down. Don't emit an error and don't do any more RPCs, just exit.
|
|
211
|
+
if (err.code === grpc.status.UNAVAILABLE || err.code === grpc.status.CANCELLED) {
|
|
212
|
+
settings_1.terminateRpcs();
|
|
213
|
+
err.message = "Resource monitor is terminating";
|
|
214
|
+
innerReject(err);
|
|
215
|
+
return;
|
|
233
216
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
217
|
+
// If the RPC failed, rethrow the error with a native exception and the message that
|
|
218
|
+
// the engine provided - it's suitable for user presentation.
|
|
219
|
+
innerReject(new Error(err.details));
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
innerResolve(innerResponse);
|
|
223
|
+
}
|
|
224
|
+
})), label);
|
|
225
|
+
const flatDependencies = dependsOnDeps;
|
|
226
|
+
for (const dep of deps.values()) {
|
|
227
|
+
for (const d of dep) {
|
|
228
|
+
if (!flatDependencies.includes(d)) {
|
|
229
|
+
flatDependencies.push(d);
|
|
241
230
|
}
|
|
242
231
|
}
|
|
243
|
-
// Finally propagate any other properties that were given to us as outputs.
|
|
244
|
-
const deserialized = deserializeResponse(tok, resp);
|
|
245
|
-
return {
|
|
246
|
-
result: deserialized.result,
|
|
247
|
-
containsSecrets: deserialized.containsSecrets || inputsContainSecrets,
|
|
248
|
-
dependencies: flatDependencies,
|
|
249
|
-
isKnown: true,
|
|
250
|
-
};
|
|
251
232
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
233
|
+
// Finally propagate any other properties that were given to us as outputs.
|
|
234
|
+
const deserialized = deserializeResponse(tok, resp);
|
|
235
|
+
return {
|
|
236
|
+
result: deserialized.result,
|
|
237
|
+
containsSecrets: deserialized.containsSecrets || inputsContainSecrets,
|
|
238
|
+
dependencies: flatDependencies,
|
|
239
|
+
isKnown: true,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
done();
|
|
244
|
+
}
|
|
256
245
|
}
|
|
257
|
-
function createInvokeRequest(tok, serialized, provider, opts, packageRef) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
opts.pluginDownloadURL = undefined;
|
|
270
|
-
}
|
|
246
|
+
async function createInvokeRequest(tok, serialized, provider, opts, packageRef) {
|
|
247
|
+
if (provider !== undefined && typeof provider !== "string") {
|
|
248
|
+
throw new Error("Incorrect provider type.");
|
|
249
|
+
}
|
|
250
|
+
const obj = gstruct.Struct.fromJavaScript(serialized);
|
|
251
|
+
let packageRefStr = undefined;
|
|
252
|
+
if (packageRef !== undefined) {
|
|
253
|
+
packageRefStr = await packageRef;
|
|
254
|
+
if (packageRefStr !== undefined) {
|
|
255
|
+
// If we have a package reference we can clear some of the resource options
|
|
256
|
+
opts.version = undefined;
|
|
257
|
+
opts.pluginDownloadURL = undefined;
|
|
271
258
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
259
|
+
}
|
|
260
|
+
const req = new resourceproto.ResourceInvokeRequest();
|
|
261
|
+
req.setTok(tok);
|
|
262
|
+
req.setArgs(obj);
|
|
263
|
+
req.setProvider(provider || "");
|
|
264
|
+
req.setVersion(opts.version || "");
|
|
265
|
+
req.setPlugindownloadurl(opts.pluginDownloadURL || "");
|
|
266
|
+
req.setAcceptresources(!utils.disableResourceReferences);
|
|
267
|
+
req.setPackageref(packageRefStr || "");
|
|
268
|
+
return req;
|
|
282
269
|
}
|
|
283
270
|
function getProvider(tok, opts) {
|
|
284
271
|
return opts.provider ? opts.provider : opts.parent ? opts.parent.getProvider(tok) : undefined;
|
|
285
272
|
}
|
|
286
273
|
function deserializeResponse(tok, resp) {
|
|
287
274
|
const failures = resp.getFailuresList();
|
|
288
|
-
if (failures
|
|
275
|
+
if (failures?.length) {
|
|
289
276
|
let reasons = "";
|
|
290
277
|
for (let i = 0; i < failures.length; i++) {
|
|
291
278
|
if (reasons !== "") {
|
|
@@ -322,7 +309,7 @@ function call(tok, props, res, packageRef) {
|
|
|
322
309
|
const label = `Calling function: tok=${tok}`;
|
|
323
310
|
log.debug(label + (settings_1.excessiveDebugOutput ? `, props=${JSON.stringify(props)}` : ``));
|
|
324
311
|
const [out, resolver] = createOutput(`call(${tok})`);
|
|
325
|
-
debuggable_1.debuggablePromise(Promise.resolve().then(() =>
|
|
312
|
+
debuggable_1.debuggablePromise(Promise.resolve().then(async () => {
|
|
326
313
|
const done = settings_1.rpcKeepAlive();
|
|
327
314
|
try {
|
|
328
315
|
// Construct a provider reference from the given provider, if one is available on the resource.
|
|
@@ -331,12 +318,12 @@ function call(tok, props, res, packageRef) {
|
|
|
331
318
|
let pluginDownloadURL = undefined;
|
|
332
319
|
if (res) {
|
|
333
320
|
if (res.__prov) {
|
|
334
|
-
provider =
|
|
321
|
+
provider = await resource_1.ProviderResource.register(res.__prov);
|
|
335
322
|
}
|
|
336
323
|
version = res.__version;
|
|
337
324
|
pluginDownloadURL = res.__pluginDownloadURL;
|
|
338
325
|
}
|
|
339
|
-
const [serialized, propertyDepsResources] =
|
|
326
|
+
const [serialized, propertyDepsResources] = await rpc_1.serializePropertiesReturnDeps(`call:${tok}`, props, {
|
|
340
327
|
// We keep output values when serializing inputs for call.
|
|
341
328
|
keepOutputValues: true,
|
|
342
329
|
// We exclude resource references from 'argDependencies' when serializing inputs for call.
|
|
@@ -345,9 +332,9 @@ function call(tok, props, res, packageRef) {
|
|
|
345
332
|
excludeResourceReferencesFromDependencies: true,
|
|
346
333
|
});
|
|
347
334
|
log.debug(`Call RPC prepared: tok=${tok}` + settings_1.excessiveDebugOutput ? `, obj=${JSON.stringify(serialized)}` : ``);
|
|
348
|
-
const req =
|
|
335
|
+
const req = await createCallRequest(tok, serialized, propertyDepsResources, provider, version, pluginDownloadURL, packageRef);
|
|
349
336
|
const monitor = settings_1.getMonitor();
|
|
350
|
-
const resp =
|
|
337
|
+
const resp = await debuggable_1.debuggablePromise(new Promise((innerResolve, innerReject) => {
|
|
351
338
|
if (monitor === undefined) {
|
|
352
339
|
throw new Error("No monitor available");
|
|
353
340
|
}
|
|
@@ -398,7 +385,7 @@ function call(tok, props, res, packageRef) {
|
|
|
398
385
|
finally {
|
|
399
386
|
done();
|
|
400
387
|
}
|
|
401
|
-
})
|
|
388
|
+
}), label);
|
|
402
389
|
return out;
|
|
403
390
|
}
|
|
404
391
|
exports.call = call;
|
|
@@ -440,40 +427,38 @@ function createOutput(label) {
|
|
|
440
427
|
}), `${label}Deps`));
|
|
441
428
|
return [out, resolver];
|
|
442
429
|
}
|
|
443
|
-
function createCallRequest(tok, serialized, serializedDeps, provider, version, pluginDownloadURL, packageRef) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
pluginDownloadURL = undefined;
|
|
456
|
-
}
|
|
430
|
+
async function createCallRequest(tok, serialized, serializedDeps, provider, version, pluginDownloadURL, packageRef) {
|
|
431
|
+
if (provider !== undefined && typeof provider !== "string") {
|
|
432
|
+
throw new Error("Incorrect provider type.");
|
|
433
|
+
}
|
|
434
|
+
const obj = gstruct.Struct.fromJavaScript(serialized);
|
|
435
|
+
let packageRefStr = undefined;
|
|
436
|
+
if (packageRef !== undefined) {
|
|
437
|
+
packageRefStr = await packageRef;
|
|
438
|
+
if (packageRefStr !== undefined) {
|
|
439
|
+
// If we have a package reference we can clear some of the resource options
|
|
440
|
+
version = undefined;
|
|
441
|
+
pluginDownloadURL = undefined;
|
|
457
442
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
const deps = new resourceproto.ResourceCallRequest.ArgumentDependencies();
|
|
473
|
-
deps.setUrnsList(Array.from(urns));
|
|
474
|
-
argDependencies.set(key, deps);
|
|
443
|
+
}
|
|
444
|
+
const req = new resourceproto.ResourceCallRequest();
|
|
445
|
+
req.setTok(tok);
|
|
446
|
+
req.setArgs(obj);
|
|
447
|
+
req.setProvider(provider || "");
|
|
448
|
+
req.setVersion(version || "");
|
|
449
|
+
req.setPlugindownloadurl(pluginDownloadURL || "");
|
|
450
|
+
req.setPackageref(packageRefStr || "");
|
|
451
|
+
const argDependencies = req.getArgdependenciesMap();
|
|
452
|
+
for (const [key, propertyDeps] of serializedDeps) {
|
|
453
|
+
const urns = new Set();
|
|
454
|
+
for (const dep of propertyDeps) {
|
|
455
|
+
const urn = await dep.urn.promise();
|
|
456
|
+
urns.add(urn);
|
|
475
457
|
}
|
|
476
|
-
|
|
477
|
-
|
|
458
|
+
const deps = new resourceproto.ResourceCallRequest.ArgumentDependencies();
|
|
459
|
+
deps.setUrnsList(Array.from(urns));
|
|
460
|
+
argDependencies.set(key, deps);
|
|
461
|
+
}
|
|
462
|
+
return req;
|
|
478
463
|
}
|
|
479
464
|
//# sourceMappingURL=invoke.js.map
|