@pulumi/pulumi 3.163.0-alpha.xdc88586 → 3.163.0-alpha.xffc5a7c
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/resource.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 = {};
|
|
@@ -71,8 +62,8 @@ function getResource(res, parent, props, custom, urn) {
|
|
|
71
62
|
const resopAsync = prepareResource(label, res, parent, custom, false, props, {});
|
|
72
63
|
const preallocError = new Error();
|
|
73
64
|
debuggable_1.debuggablePromise(resopAsync
|
|
74
|
-
.then((resop) =>
|
|
75
|
-
const inputs =
|
|
65
|
+
.then(async (resop) => {
|
|
66
|
+
const inputs = await rpc_1.serializeProperties(label, { urn });
|
|
76
67
|
const req = new resproto.ResourceInvokeRequest();
|
|
77
68
|
req.setTok("pulumi:pulumi:getResource");
|
|
78
69
|
req.setArgs(gstruct.Struct.fromJavaScript(inputs));
|
|
@@ -81,12 +72,12 @@ function getResource(res, parent, props, custom, urn) {
|
|
|
81
72
|
req.setAcceptresources(!utils.disableResourceReferences);
|
|
82
73
|
// Now run the operation, serializing the invocation if necessary.
|
|
83
74
|
const opLabel = `monitor.getResource(${label})`;
|
|
84
|
-
runAsyncResourceOp(opLabel, () =>
|
|
75
|
+
runAsyncResourceOp(opLabel, async () => {
|
|
85
76
|
let resp = {};
|
|
86
77
|
let err;
|
|
87
78
|
try {
|
|
88
79
|
if (monitor) {
|
|
89
|
-
resp =
|
|
80
|
+
resp = await debuggable_1.debuggablePromise(new Promise((resolve, reject) => monitor.invoke(req, (rpcError, innerResponse) => {
|
|
90
81
|
log.debug(`getResource Invoke RPC finished: err: ${rpcError}, resp: ${innerResponse}`);
|
|
91
82
|
if (rpcError) {
|
|
92
83
|
if (rpcError.code === grpc.status.UNAVAILABLE ||
|
|
@@ -105,7 +96,7 @@ function getResource(res, parent, props, custom, urn) {
|
|
|
105
96
|
})), opLabel);
|
|
106
97
|
// If the invoke failed, raise an error
|
|
107
98
|
const failures = resp.getFailuresList();
|
|
108
|
-
if (failures
|
|
99
|
+
if (failures?.length) {
|
|
109
100
|
let reasons = "";
|
|
110
101
|
for (let i = 0; i < failures.length; i++) {
|
|
111
102
|
if (reasons !== "") {
|
|
@@ -139,10 +130,10 @@ function getResource(res, parent, props, custom, urn) {
|
|
|
139
130
|
const id = resp.id || undefined;
|
|
140
131
|
resop.resolveID(id, id !== undefined, err);
|
|
141
132
|
}
|
|
142
|
-
|
|
133
|
+
await resolveOutputs(res, type, urnName, props, resp.state, {}, resop.resolvers, err);
|
|
143
134
|
done();
|
|
144
|
-
})
|
|
145
|
-
})
|
|
135
|
+
});
|
|
136
|
+
})
|
|
146
137
|
.catch((err) => {
|
|
147
138
|
done();
|
|
148
139
|
throw err;
|
|
@@ -167,13 +158,13 @@ function readResource(res, parent, t, name, props, opts, sourcePosition, package
|
|
|
167
158
|
const resopAsync = prepareResource(label, res, parent, true, false, props, opts);
|
|
168
159
|
const preallocError = new Error();
|
|
169
160
|
debuggable_1.debuggablePromise(resopAsync
|
|
170
|
-
.then((resop) =>
|
|
171
|
-
const resolvedID =
|
|
161
|
+
.then(async (resop) => {
|
|
162
|
+
const resolvedID = await rpc_1.serializeProperty(label, await id, new Set(), { keepOutputValues: false });
|
|
172
163
|
log.debug(`ReadResource RPC prepared: id=${resolvedID}, t=${t}, name=${name}` +
|
|
173
164
|
(settings_1.excessiveDebugOutput ? `, obj=${JSON.stringify(resop.serializedProps)}` : ``));
|
|
174
165
|
let packageRefStr = undefined;
|
|
175
166
|
if (packageRef !== undefined) {
|
|
176
|
-
packageRefStr =
|
|
167
|
+
packageRefStr = await packageRef;
|
|
177
168
|
if (packageRefStr !== undefined) {
|
|
178
169
|
// If we have a package reference we can clear some of the resource options
|
|
179
170
|
opts.version = undefined;
|
|
@@ -198,13 +189,13 @@ function readResource(res, parent, t, name, props, opts, sourcePosition, package
|
|
|
198
189
|
req.setPackageref(packageRefStr || "");
|
|
199
190
|
// Now run the operation, serializing the invocation if necessary.
|
|
200
191
|
const opLabel = `monitor.readResource(${label})`;
|
|
201
|
-
runAsyncResourceOp(opLabel, () =>
|
|
192
|
+
runAsyncResourceOp(opLabel, async () => {
|
|
202
193
|
let resp = {};
|
|
203
194
|
let err;
|
|
204
195
|
try {
|
|
205
196
|
if (monitor) {
|
|
206
197
|
// If we're attached to the engine, make an RPC call and wait for it to resolve.
|
|
207
|
-
resp =
|
|
198
|
+
resp = await debuggable_1.debuggablePromise(new Promise((resolve, reject) => monitor.readResource(req, (rpcError, innerResponse) => {
|
|
208
199
|
log.debug(`ReadResource RPC finished: ${label}; err: ${rpcError}, resp: ${innerResponse}`);
|
|
209
200
|
if (rpcError) {
|
|
210
201
|
if (rpcError.code === grpc.status.UNAVAILABLE ||
|
|
@@ -224,7 +215,7 @@ function readResource(res, parent, t, name, props, opts, sourcePosition, package
|
|
|
224
215
|
}
|
|
225
216
|
else {
|
|
226
217
|
// If we aren't attached to the engine, in test mode, mock up a fake response for testing purposes.
|
|
227
|
-
const mockurn =
|
|
218
|
+
const mockurn = await resource_1.createUrn(req.getName(), req.getType(), req.getParent()).promise();
|
|
228
219
|
resp = {
|
|
229
220
|
getUrn: () => mockurn,
|
|
230
221
|
getProperties: () => req.getProperties(),
|
|
@@ -241,10 +232,10 @@ function readResource(res, parent, t, name, props, opts, sourcePosition, package
|
|
|
241
232
|
// Now resolve everything: the URN, the ID (supplied as input), and the output properties.
|
|
242
233
|
resop.resolveURN(resp.getUrn(), err);
|
|
243
234
|
resop.resolveID(resolvedID, resolvedID !== undefined, err);
|
|
244
|
-
|
|
235
|
+
await resolveOutputs(res, t, name, props, resp.getProperties(), {}, resop.resolvers, err);
|
|
245
236
|
done();
|
|
246
|
-
})
|
|
247
|
-
})
|
|
237
|
+
});
|
|
238
|
+
})
|
|
248
239
|
.catch((err) => {
|
|
249
240
|
done();
|
|
250
241
|
throw err;
|
|
@@ -261,17 +252,17 @@ function mapAliasesForRequest(aliases, parentURN) {
|
|
|
261
252
|
if (aliases === undefined) {
|
|
262
253
|
return Promise.resolve([]);
|
|
263
254
|
}
|
|
264
|
-
return Promise.all(aliases.map((a) =>
|
|
255
|
+
return Promise.all(aliases.map(async (a) => {
|
|
265
256
|
const newAlias = new aliasproto.Alias();
|
|
266
257
|
if (typeof a === "string") {
|
|
267
258
|
newAlias.setUrn(a);
|
|
268
259
|
}
|
|
269
260
|
else {
|
|
270
261
|
const newAliasSpec = new aliasproto.Alias.Spec();
|
|
271
|
-
const name = a.name === undefined ? undefined :
|
|
272
|
-
const type = a.type === undefined ? undefined :
|
|
273
|
-
const stack = a.stack === undefined ? undefined :
|
|
274
|
-
const project = a.project === undefined ? undefined :
|
|
262
|
+
const name = a.name === undefined ? undefined : await output_1.output(a.name).promise();
|
|
263
|
+
const type = a.type === undefined ? undefined : await output_1.output(a.type).promise();
|
|
264
|
+
const stack = a.stack === undefined ? undefined : await output_1.output(a.stack).promise();
|
|
265
|
+
const project = a.project === undefined ? undefined : await output_1.output(a.project).promise();
|
|
275
266
|
newAliasSpec.setName(name || "");
|
|
276
267
|
newAliasSpec.setType(type || "");
|
|
277
268
|
newAliasSpec.setStack(stack || "");
|
|
@@ -282,7 +273,7 @@ function mapAliasesForRequest(aliases, parentURN) {
|
|
|
282
273
|
}
|
|
283
274
|
else {
|
|
284
275
|
const aliasParentUrn = getParentURN(a.parent);
|
|
285
|
-
const urn =
|
|
276
|
+
const urn = await aliasParentUrn.promise();
|
|
286
277
|
if (urn !== undefined) {
|
|
287
278
|
newAliasSpec.setParenturn(urn);
|
|
288
279
|
}
|
|
@@ -301,7 +292,7 @@ function mapAliasesForRequest(aliases, parentURN) {
|
|
|
301
292
|
newAlias.setSpec(newAliasSpec);
|
|
302
293
|
}
|
|
303
294
|
return newAlias;
|
|
304
|
-
}))
|
|
295
|
+
}));
|
|
305
296
|
}
|
|
306
297
|
exports.mapAliasesForRequest = mapAliasesForRequest;
|
|
307
298
|
/**
|
|
@@ -324,10 +315,10 @@ function registerResource(res, parent, t, name, custom, remote, newDependency, p
|
|
|
324
315
|
// with a non-useful stack trace.
|
|
325
316
|
const preallocError = new Error();
|
|
326
317
|
debuggable_1.debuggablePromise(resopAsync
|
|
327
|
-
.then((resop) =>
|
|
318
|
+
.then(async (resop) => {
|
|
328
319
|
log.debug(`RegisterResource RPC prepared: t=${t}, name=${name}` +
|
|
329
320
|
(settings_1.excessiveDebugOutput ? `, obj=${JSON.stringify(resop.serializedProps)}` : ``));
|
|
330
|
-
|
|
321
|
+
await settings_1.awaitStackRegistrations();
|
|
331
322
|
const callbacks = [];
|
|
332
323
|
if (opts.transforms !== undefined && opts.transforms.length > 0) {
|
|
333
324
|
if (!state_1.getStore().supportsTransforms) {
|
|
@@ -338,13 +329,13 @@ function registerResource(res, parent, t, name, custom, remote, newDependency, p
|
|
|
338
329
|
throw new Error("Callback server could not initialize");
|
|
339
330
|
}
|
|
340
331
|
for (const transform of opts.transforms) {
|
|
341
|
-
callbacks.push(
|
|
332
|
+
callbacks.push(await callbackServer.registerTransform(transform));
|
|
342
333
|
}
|
|
343
334
|
}
|
|
344
335
|
// If we have a package reference, we need to wait for it to resolve.
|
|
345
336
|
let packageRefStr = undefined;
|
|
346
337
|
if (packageRef !== undefined) {
|
|
347
|
-
packageRefStr =
|
|
338
|
+
packageRefStr = await packageRef;
|
|
348
339
|
if (packageRefStr !== undefined) {
|
|
349
340
|
// If we have a package reference we can clear some of the resource options
|
|
350
341
|
opts.version = undefined;
|
|
@@ -371,7 +362,7 @@ function registerResource(res, parent, t, name, custom, remote, newDependency, p
|
|
|
371
362
|
req.setAcceptresources(!utils.disableResourceReferences);
|
|
372
363
|
req.setAdditionalsecretoutputsList(opts.additionalSecretOutputs || []);
|
|
373
364
|
if (resop.monitorSupportsStructuredAliases) {
|
|
374
|
-
const aliasesList =
|
|
365
|
+
const aliasesList = await mapAliasesForRequest(resop.aliases, resop.parentURN);
|
|
375
366
|
req.setAliasesList(aliasesList);
|
|
376
367
|
}
|
|
377
368
|
else {
|
|
@@ -418,13 +409,13 @@ function registerResource(res, parent, t, name, custom, remote, newDependency, p
|
|
|
418
409
|
}
|
|
419
410
|
// Now run the operation, serializing the invocation if necessary.
|
|
420
411
|
const opLabel = `monitor.registerResource(${label})`;
|
|
421
|
-
runAsyncResourceOp(opLabel, () =>
|
|
412
|
+
runAsyncResourceOp(opLabel, async () => {
|
|
422
413
|
let resp = {};
|
|
423
414
|
let err;
|
|
424
415
|
try {
|
|
425
416
|
if (monitor) {
|
|
426
417
|
// If we're running with an attachment to the engine, perform the operation.
|
|
427
|
-
resp =
|
|
418
|
+
resp = await debuggable_1.debuggablePromise(new Promise((resolve, reject) => monitor.registerResource(req, (rpcErr, innerResponse) => {
|
|
428
419
|
if (rpcErr) {
|
|
429
420
|
err = rpcErr;
|
|
430
421
|
// If the monitor is unavailable, it is in the process of shutting down or has already
|
|
@@ -449,7 +440,7 @@ function registerResource(res, parent, t, name, custom, remote, newDependency, p
|
|
|
449
440
|
}
|
|
450
441
|
else {
|
|
451
442
|
// If we aren't attached to the engine, in test mode, mock up a fake response for testing purposes.
|
|
452
|
-
const mockurn =
|
|
443
|
+
const mockurn = await resource_1.createUrn(req.getName(), req.getType(), req.getParent()).promise();
|
|
453
444
|
resp = {
|
|
454
445
|
getUrn: () => mockurn,
|
|
455
446
|
getId: () => undefined,
|
|
@@ -486,10 +477,10 @@ function registerResource(res, parent, t, name, custom, remote, newDependency, p
|
|
|
486
477
|
}
|
|
487
478
|
// Now resolve the output properties.
|
|
488
479
|
const keepUnknowns = resp.getResult() !== resproto.Result.SUCCESS;
|
|
489
|
-
|
|
480
|
+
await resolveOutputs(res, t, name, props, resp.getObject(), deps, resop.resolvers, err, keepUnknowns);
|
|
490
481
|
done();
|
|
491
|
-
})
|
|
492
|
-
})
|
|
482
|
+
});
|
|
483
|
+
})
|
|
493
484
|
.catch((err) => {
|
|
494
485
|
// If we fail to prepare the resource, we need to ensure that we still call done to prevent a hang.
|
|
495
486
|
done();
|
|
@@ -503,196 +494,193 @@ exports.registerResource = registerResource;
|
|
|
503
494
|
*
|
|
504
495
|
* @internal
|
|
505
496
|
*/
|
|
506
|
-
function prepareResource(label, res, parent, custom, remote, props, opts, type, name) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
let
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
if (debuggable_1.debugPromiseLeaks) {
|
|
530
|
-
console.error("info: skipped rejection in resolveURN");
|
|
531
|
-
}
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
rejectValue(err);
|
|
535
|
-
rejectIsKnown(err);
|
|
536
|
-
}
|
|
537
|
-
else {
|
|
538
|
-
resolveValue(v);
|
|
539
|
-
resolveIsKnown(true);
|
|
540
|
-
}
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
// If a custom resource, make room for the ID property.
|
|
544
|
-
let resolveID;
|
|
545
|
-
if (custom) {
|
|
546
|
-
let resolveValue;
|
|
547
|
-
let rejectValue;
|
|
548
|
-
let resolveIsKnown;
|
|
549
|
-
let rejectIsKnown;
|
|
550
|
-
res.id = new output_1.Output(res, debuggable_1.debuggablePromise(new Promise((resolve, reject) => {
|
|
551
|
-
resolveValue = resolve;
|
|
552
|
-
rejectValue = reject;
|
|
553
|
-
}), `resolveID(${label})`), debuggable_1.debuggablePromise(new Promise((resolve, reject) => {
|
|
554
|
-
resolveIsKnown = resolve;
|
|
555
|
-
rejectIsKnown = reject;
|
|
556
|
-
}), `resolveIDIsKnown(${label})`), Promise.resolve(false), Promise.resolve(res));
|
|
557
|
-
resolveID = (v, isKnown, err) => {
|
|
558
|
-
if (err) {
|
|
559
|
-
if (errors_1.isGrpcError(err)) {
|
|
560
|
-
if (debuggable_1.debugPromiseLeaks) {
|
|
561
|
-
console.error("info: skipped rejection in resolveID");
|
|
562
|
-
}
|
|
563
|
-
return;
|
|
497
|
+
async function prepareResource(label, res, parent, custom, remote, props, opts, type, name) {
|
|
498
|
+
// Simply initialize the URN property and get prepared to resolve it later on.
|
|
499
|
+
// Note: a resource urn will always get a value, and thus the output property
|
|
500
|
+
// for it can always run .apply calls.
|
|
501
|
+
let resolveURN;
|
|
502
|
+
{
|
|
503
|
+
let resolveValue;
|
|
504
|
+
let rejectValue;
|
|
505
|
+
let resolveIsKnown;
|
|
506
|
+
let rejectIsKnown;
|
|
507
|
+
res.urn = new output_1.Output(res, debuggable_1.debuggablePromise(new Promise((resolve, reject) => {
|
|
508
|
+
resolveValue = resolve;
|
|
509
|
+
rejectValue = reject;
|
|
510
|
+
}), `resolveURN(${label})`), debuggable_1.debuggablePromise(new Promise((resolve, reject) => {
|
|
511
|
+
resolveIsKnown = resolve;
|
|
512
|
+
rejectIsKnown = reject;
|
|
513
|
+
}), `resolveURNIsKnown(${label})`),
|
|
514
|
+
/*isSecret:*/ Promise.resolve(false), Promise.resolve(res));
|
|
515
|
+
resolveURN = (v, err) => {
|
|
516
|
+
if (err) {
|
|
517
|
+
if (errors_1.isGrpcError(err)) {
|
|
518
|
+
if (debuggable_1.debugPromiseLeaks) {
|
|
519
|
+
console.error("info: skipped rejection in resolveURN");
|
|
564
520
|
}
|
|
565
|
-
|
|
566
|
-
rejectIsKnown(err);
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
resolveValue(v);
|
|
570
|
-
resolveIsKnown(isKnown);
|
|
521
|
+
return;
|
|
571
522
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
// Now "transfer" all input properties into unresolved Promises on res. This way,
|
|
575
|
-
// this resource will look like it has all its output properties to anyone it is
|
|
576
|
-
// passed to. However, those promises won't actually resolve until the registerResource
|
|
577
|
-
// RPC returns
|
|
578
|
-
const resolvers = rpc_1.transferProperties(res, label, props);
|
|
579
|
-
/** IMPORTANT! We should never await prior to this line, otherwise the Resource will be partly uninitialized. */
|
|
580
|
-
// Before we can proceed, all our dependencies must be finished.
|
|
581
|
-
const explicitDirectDependencies = new Set(yield dependsOn_1.gatherExplicitDependencies(opts.dependsOn));
|
|
582
|
-
// Serialize out all our props to their final values. In doing so, we'll also collect all
|
|
583
|
-
// the Resources pointed to by any Dependency objects we encounter, adding them to 'propertyDependencies'.
|
|
584
|
-
const [serializedProps, propertyToDirectDependencies] = yield rpc_1.serializeResourceProperties(label, props, {
|
|
585
|
-
// To initially scope the use of this new feature, we only keep output values when
|
|
586
|
-
// remote is true (for multi-lang components, i.e. MLCs).
|
|
587
|
-
keepOutputValues: remote,
|
|
588
|
-
// When remote is true, exclude resource references from 'propertyDependencies'.
|
|
589
|
-
// This way, component providers creating outputs for component inputs based
|
|
590
|
-
// on 'propertyDependencies' won't create outputs for properties that only
|
|
591
|
-
// contain resource references.
|
|
592
|
-
excludeResourceReferencesFromDependencies: remote,
|
|
593
|
-
});
|
|
594
|
-
// Wait for the parent to complete.
|
|
595
|
-
// If no parent was provided, parent to the root resource.
|
|
596
|
-
const parentURN = parent ? yield parent.urn.promise() : undefined;
|
|
597
|
-
let importID;
|
|
598
|
-
if (custom) {
|
|
599
|
-
const customOpts = opts;
|
|
600
|
-
importID = customOpts.import;
|
|
601
|
-
}
|
|
602
|
-
let providerRef;
|
|
603
|
-
let sendProvider = custom;
|
|
604
|
-
if (remote && opts.provider) {
|
|
605
|
-
// If it's a remote component and a provider was specified, only
|
|
606
|
-
// send the provider in the request if the provider's package is
|
|
607
|
-
// the same as the component's package. Otherwise, don't send it
|
|
608
|
-
// because the user specified `provider: someProvider` as shorthand
|
|
609
|
-
// for `providers: [someProvider]`.
|
|
610
|
-
const pkg = resource_1.pkgFromType(type);
|
|
611
|
-
if (pkg && pkg === opts.provider.getPackage()) {
|
|
612
|
-
sendProvider = true;
|
|
523
|
+
rejectValue(err);
|
|
524
|
+
rejectIsKnown(err);
|
|
613
525
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
618
|
-
const providerRefs = new Map();
|
|
619
|
-
if (remote || !custom) {
|
|
620
|
-
const componentOpts = opts;
|
|
621
|
-
resource_1.expandProviders(componentOpts);
|
|
622
|
-
// the <ProviderResource[]> casts are safe because expandProviders
|
|
623
|
-
// /always/ leaves providers as an array.
|
|
624
|
-
if (componentOpts.provider !== undefined) {
|
|
625
|
-
if (componentOpts.providers === undefined) {
|
|
626
|
-
// We still want to do the promotion, so we define providers
|
|
627
|
-
componentOpts.providers = [componentOpts.provider];
|
|
628
|
-
}
|
|
629
|
-
else if (((_a = componentOpts.providers) === null || _a === void 0 ? void 0 : _a.indexOf(componentOpts.provider)) !== -1) {
|
|
630
|
-
const pkg = componentOpts.provider.getPackage();
|
|
631
|
-
const message = `There is a conflict between the 'provider' field (${pkg}) and a member of the 'providers' map'. `;
|
|
632
|
-
const deprecationd = "This will become an error in a future version. See https://github.com/pulumi/pulumi/issues/8799 for more details";
|
|
633
|
-
log.warn(message + deprecationd);
|
|
634
|
-
}
|
|
635
|
-
else {
|
|
636
|
-
componentOpts.providers.push(componentOpts.provider);
|
|
637
|
-
}
|
|
526
|
+
else {
|
|
527
|
+
resolveValue(v);
|
|
528
|
+
resolveIsKnown(true);
|
|
638
529
|
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
// If a custom resource, make room for the ID property.
|
|
533
|
+
let resolveID;
|
|
534
|
+
if (custom) {
|
|
535
|
+
let resolveValue;
|
|
536
|
+
let rejectValue;
|
|
537
|
+
let resolveIsKnown;
|
|
538
|
+
let rejectIsKnown;
|
|
539
|
+
res.id = new output_1.Output(res, debuggable_1.debuggablePromise(new Promise((resolve, reject) => {
|
|
540
|
+
resolveValue = resolve;
|
|
541
|
+
rejectValue = reject;
|
|
542
|
+
}), `resolveID(${label})`), debuggable_1.debuggablePromise(new Promise((resolve, reject) => {
|
|
543
|
+
resolveIsKnown = resolve;
|
|
544
|
+
rejectIsKnown = reject;
|
|
545
|
+
}), `resolveIDIsKnown(${label})`), Promise.resolve(false), Promise.resolve(res));
|
|
546
|
+
resolveID = (v, isKnown, err) => {
|
|
547
|
+
if (err) {
|
|
548
|
+
if (errors_1.isGrpcError(err)) {
|
|
549
|
+
if (debuggable_1.debugPromiseLeaks) {
|
|
550
|
+
console.error("info: skipped rejection in resolveID");
|
|
644
551
|
}
|
|
552
|
+
return;
|
|
645
553
|
}
|
|
554
|
+
rejectValue(err);
|
|
555
|
+
rejectIsKnown(err);
|
|
646
556
|
}
|
|
557
|
+
else {
|
|
558
|
+
resolveValue(v);
|
|
559
|
+
resolveIsKnown(isKnown);
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
// Now "transfer" all input properties into unresolved Promises on res. This way,
|
|
564
|
+
// this resource will look like it has all its output properties to anyone it is
|
|
565
|
+
// passed to. However, those promises won't actually resolve until the registerResource
|
|
566
|
+
// RPC returns
|
|
567
|
+
const resolvers = rpc_1.transferProperties(res, label, props);
|
|
568
|
+
/** IMPORTANT! We should never await prior to this line, otherwise the Resource will be partly uninitialized. */
|
|
569
|
+
// Before we can proceed, all our dependencies must be finished.
|
|
570
|
+
const explicitDirectDependencies = new Set(await dependsOn_1.gatherExplicitDependencies(opts.dependsOn));
|
|
571
|
+
// Serialize out all our props to their final values. In doing so, we'll also collect all
|
|
572
|
+
// the Resources pointed to by any Dependency objects we encounter, adding them to 'propertyDependencies'.
|
|
573
|
+
const [serializedProps, propertyToDirectDependencies] = await rpc_1.serializeResourceProperties(label, props, {
|
|
574
|
+
// To initially scope the use of this new feature, we only keep output values when
|
|
575
|
+
// remote is true (for multi-lang components, i.e. MLCs).
|
|
576
|
+
keepOutputValues: remote,
|
|
577
|
+
// When remote is true, exclude resource references from 'propertyDependencies'.
|
|
578
|
+
// This way, component providers creating outputs for component inputs based
|
|
579
|
+
// on 'propertyDependencies' won't create outputs for properties that only
|
|
580
|
+
// contain resource references.
|
|
581
|
+
excludeResourceReferencesFromDependencies: remote,
|
|
582
|
+
});
|
|
583
|
+
// Wait for the parent to complete.
|
|
584
|
+
// If no parent was provided, parent to the root resource.
|
|
585
|
+
const parentURN = parent ? await parent.urn.promise() : undefined;
|
|
586
|
+
let importID;
|
|
587
|
+
if (custom) {
|
|
588
|
+
const customOpts = opts;
|
|
589
|
+
importID = customOpts.import;
|
|
590
|
+
}
|
|
591
|
+
let providerRef;
|
|
592
|
+
let sendProvider = custom;
|
|
593
|
+
if (remote && opts.provider) {
|
|
594
|
+
// If it's a remote component and a provider was specified, only
|
|
595
|
+
// send the provider in the request if the provider's package is
|
|
596
|
+
// the same as the component's package. Otherwise, don't send it
|
|
597
|
+
// because the user specified `provider: someProvider` as shorthand
|
|
598
|
+
// for `providers: [someProvider]`.
|
|
599
|
+
const pkg = resource_1.pkgFromType(type);
|
|
600
|
+
if (pkg && pkg === opts.provider.getPackage()) {
|
|
601
|
+
sendProvider = true;
|
|
647
602
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
603
|
+
}
|
|
604
|
+
if (sendProvider) {
|
|
605
|
+
providerRef = await resource_1.ProviderResource.register(opts.provider);
|
|
606
|
+
}
|
|
607
|
+
const providerRefs = new Map();
|
|
608
|
+
if (remote || !custom) {
|
|
609
|
+
const componentOpts = opts;
|
|
610
|
+
resource_1.expandProviders(componentOpts);
|
|
611
|
+
// the <ProviderResource[]> casts are safe because expandProviders
|
|
612
|
+
// /always/ leaves providers as an array.
|
|
613
|
+
if (componentOpts.provider !== undefined) {
|
|
614
|
+
if (componentOpts.providers === undefined) {
|
|
615
|
+
// We still want to do the promotion, so we define providers
|
|
616
|
+
componentOpts.providers = [componentOpts.provider];
|
|
617
|
+
}
|
|
618
|
+
else if (componentOpts.providers?.indexOf(componentOpts.provider) !== -1) {
|
|
619
|
+
const pkg = componentOpts.provider.getPackage();
|
|
620
|
+
const message = `There is a conflict between the 'provider' field (${pkg}) and a member of the 'providers' map'. `;
|
|
621
|
+
const deprecationd = "This will become an error in a future version. See https://github.com/pulumi/pulumi/issues/8799 for more details";
|
|
622
|
+
log.warn(message + deprecationd);
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
componentOpts.providers.push(componentOpts.provider);
|
|
626
|
+
}
|
|
668
627
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
uniqueAliases.add(aliasVal);
|
|
676
|
-
aliases.push(aliasVal);
|
|
628
|
+
if (componentOpts.providers) {
|
|
629
|
+
for (const provider of componentOpts.providers) {
|
|
630
|
+
const pref = await resource_1.ProviderResource.register(provider);
|
|
631
|
+
if (pref) {
|
|
632
|
+
providerRefs.set(provider.getPackage(), pref);
|
|
633
|
+
}
|
|
677
634
|
}
|
|
678
635
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
636
|
+
}
|
|
637
|
+
// Collect the URNs for explicit/implicit dependencies for the engine so that it can understand
|
|
638
|
+
// the dependency graph and optimize operations accordingly.
|
|
639
|
+
// The list of all dependencies (implicit or explicit).
|
|
640
|
+
const allDirectDependencies = new Set(explicitDirectDependencies);
|
|
641
|
+
const exclude = new Set([res]);
|
|
642
|
+
const allDirectDependencyURNs = await dependsOn_1.getAllTransitivelyReferencedResourceURNs(explicitDirectDependencies, exclude);
|
|
643
|
+
const propertyToDirectDependencyURNs = new Map();
|
|
644
|
+
for (const [propertyName, directDependencies] of propertyToDirectDependencies) {
|
|
645
|
+
addAll(allDirectDependencies, directDependencies);
|
|
646
|
+
const urns = await dependsOn_1.getAllTransitivelyReferencedResourceURNs(directDependencies, exclude);
|
|
647
|
+
addAll(allDirectDependencyURNs, urns);
|
|
648
|
+
propertyToDirectDependencyURNs.set(propertyName, urns);
|
|
649
|
+
}
|
|
650
|
+
const monitorSupportsStructuredAliases = state_1.getStore().supportsAliasSpecs;
|
|
651
|
+
let computedAliases;
|
|
652
|
+
if (!monitorSupportsStructuredAliases && parent) {
|
|
653
|
+
computedAliases = resource_1.allAliases(opts.aliases || [], name, type, parent, parent.__name);
|
|
654
|
+
}
|
|
655
|
+
else {
|
|
656
|
+
computedAliases = opts.aliases || [];
|
|
657
|
+
}
|
|
658
|
+
// Wait for all aliases.
|
|
659
|
+
const aliases = [];
|
|
660
|
+
const uniqueAliases = new Set();
|
|
661
|
+
for (const alias of computedAliases || []) {
|
|
662
|
+
const aliasVal = await output_1.output(alias).promise();
|
|
663
|
+
if (!uniqueAliases.has(aliasVal)) {
|
|
664
|
+
uniqueAliases.add(aliasVal);
|
|
665
|
+
aliases.push(aliasVal);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
const deletedWithURN = opts?.deletedWith ? await opts.deletedWith.urn.promise() : undefined;
|
|
669
|
+
return {
|
|
670
|
+
resolveURN: resolveURN,
|
|
671
|
+
resolveID: resolveID,
|
|
672
|
+
resolvers: resolvers,
|
|
673
|
+
serializedProps: serializedProps,
|
|
674
|
+
parentURN: parentURN,
|
|
675
|
+
providerRef: providerRef,
|
|
676
|
+
providerRefs: providerRefs,
|
|
677
|
+
allDirectDependencyURNs: allDirectDependencyURNs,
|
|
678
|
+
propertyToDirectDependencyURNs: propertyToDirectDependencyURNs,
|
|
679
|
+
aliases: aliases,
|
|
680
|
+
import: importID,
|
|
681
|
+
monitorSupportsStructuredAliases,
|
|
682
|
+
deletedWithURN,
|
|
683
|
+
};
|
|
696
684
|
}
|
|
697
685
|
exports.prepareResource = prepareResource;
|
|
698
686
|
function addAll(to, from) {
|
|
@@ -704,31 +692,29 @@ function addAll(to, from) {
|
|
|
704
692
|
* Finishes a resource creation RPC operation by resolving its outputs to the
|
|
705
693
|
* resulting RPC payload.
|
|
706
694
|
*/
|
|
707
|
-
function resolveOutputs(res, t, name, props, outputs, deps, resolvers, err, keepUnknowns) {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
continue;
|
|
725
|
-
}
|
|
726
|
-
allProps[key] = rpc_1.deserializeProperty(inputProp, keepUnknowns);
|
|
695
|
+
async function resolveOutputs(res, t, name, props, outputs, deps, resolvers, err, keepUnknowns) {
|
|
696
|
+
// Produce a combined set of property states, starting with inputs and then applying
|
|
697
|
+
// outputs. If the same property exists in the inputs and outputs states, the output wins.
|
|
698
|
+
const allProps = {};
|
|
699
|
+
if (outputs) {
|
|
700
|
+
Object.assign(allProps, rpc_1.deserializeProperties(outputs, keepUnknowns));
|
|
701
|
+
}
|
|
702
|
+
const label = `resource:${name}[${t}]#...`;
|
|
703
|
+
if (!settings_1.isDryRun() || settings_1.isLegacyApplyEnabled()) {
|
|
704
|
+
for (const key of Object.keys(props)) {
|
|
705
|
+
if (!allProps.hasOwnProperty(key)) {
|
|
706
|
+
// input prop the engine didn't give us a final value for. Just use the value passed into the resource
|
|
707
|
+
// after round-tripping it through serialization. We do the round-tripping primarily s.t. we ensure that
|
|
708
|
+
// Output values are handled properly w.r.t. unknowns.
|
|
709
|
+
const inputProp = await rpc_1.serializeProperty(label, props[key], new Set(), { keepOutputValues: false });
|
|
710
|
+
if (inputProp === undefined) {
|
|
711
|
+
continue;
|
|
727
712
|
}
|
|
713
|
+
allProps[key] = rpc_1.deserializeProperty(inputProp, keepUnknowns);
|
|
728
714
|
}
|
|
729
715
|
}
|
|
730
|
-
|
|
731
|
-
|
|
716
|
+
}
|
|
717
|
+
rpc_1.resolveProperties(res, resolvers, t, name, allProps, deps, err, keepUnknowns);
|
|
732
718
|
}
|
|
733
719
|
/**
|
|
734
720
|
* Completes a resource registration, attaching an optional set of computed
|
|
@@ -741,12 +727,12 @@ function registerResourceOutputs(res, outputs) {
|
|
|
741
727
|
// never resolve.
|
|
742
728
|
const opLabel = `monitor.registerResourceOutputs(...)`;
|
|
743
729
|
const done = settings_1.rpcKeepAlive();
|
|
744
|
-
runAsyncResourceOp(opLabel, () =>
|
|
730
|
+
runAsyncResourceOp(opLabel, async () => {
|
|
745
731
|
try {
|
|
746
732
|
// The registration could very well still be taking place, so we will need to wait for its URN.
|
|
747
733
|
// Additionally, the output properties might have come from other resources, so we must await those too.
|
|
748
|
-
const urn =
|
|
749
|
-
const resolved =
|
|
734
|
+
const urn = await res.urn.promise();
|
|
735
|
+
const resolved = await rpc_1.serializeProperties(opLabel, { outputs });
|
|
750
736
|
const outputsObj = gstruct.Struct.fromJavaScript(resolved.outputs);
|
|
751
737
|
log.debug(`RegisterResourceOutputs RPC prepared: urn=${urn}` +
|
|
752
738
|
(settings_1.excessiveDebugOutput ? `, outputs=${JSON.stringify(outputsObj)}` : ``));
|
|
@@ -757,7 +743,7 @@ function registerResourceOutputs(res, outputs) {
|
|
|
757
743
|
req.setUrn(urn);
|
|
758
744
|
req.setOutputs(outputsObj);
|
|
759
745
|
const label = `monitor.registerResourceOutputs(${urn}, ...)`;
|
|
760
|
-
|
|
746
|
+
await debuggable_1.debuggablePromise(new Promise((resolve, reject) => monitor.registerResourceOutputs(req, (err, innerResponse) => {
|
|
761
747
|
log.debug(`RegisterResourceOutputs RPC finished: urn=${urn}; ` +
|
|
762
748
|
`err: ${err}, resp: ${innerResponse}`);
|
|
763
749
|
if (err) {
|
|
@@ -781,7 +767,7 @@ function registerResourceOutputs(res, outputs) {
|
|
|
781
767
|
finally {
|
|
782
768
|
done();
|
|
783
769
|
}
|
|
784
|
-
}
|
|
770
|
+
}, false);
|
|
785
771
|
}
|
|
786
772
|
exports.registerResourceOutputs = registerResourceOutputs;
|
|
787
773
|
/**
|
|
@@ -803,13 +789,13 @@ function runAsyncResourceOp(label, callback, serial) {
|
|
|
803
789
|
if (serial === undefined) {
|
|
804
790
|
serial = settings_1.serialize();
|
|
805
791
|
}
|
|
806
|
-
const resourceOp = rpc_1.suppressUnhandledGrpcRejections(debuggable_1.debuggablePromise(resourceChain.then(() =>
|
|
792
|
+
const resourceOp = rpc_1.suppressUnhandledGrpcRejections(debuggable_1.debuggablePromise(resourceChain.then(async () => {
|
|
807
793
|
if (serial) {
|
|
808
794
|
resourceChainLabel = label;
|
|
809
795
|
log.debug(`Resource RPC serialization requested: ${label} is current`);
|
|
810
796
|
}
|
|
811
797
|
return callback();
|
|
812
|
-
})
|
|
798
|
+
}), label + "-initial"));
|
|
813
799
|
const finalOp = debuggable_1.debuggablePromise(resourceOp, label + "-final");
|
|
814
800
|
// Set up another promise that propagates the error, if any, so that it triggers unhandled rejection logic.
|
|
815
801
|
resourceOp.catch((err) => Promise.reject(err));
|