@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/automation/stack.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 = {};
|
|
@@ -86,12 +77,10 @@ class Stack {
|
|
|
86
77
|
* @param workspace
|
|
87
78
|
* The Workspace the Stack was created from.
|
|
88
79
|
*/
|
|
89
|
-
static create(name, workspace) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return stack;
|
|
94
|
-
});
|
|
80
|
+
static async create(name, workspace) {
|
|
81
|
+
const stack = new Stack(name, workspace, "create");
|
|
82
|
+
await stack.ready;
|
|
83
|
+
return stack;
|
|
95
84
|
}
|
|
96
85
|
/**
|
|
97
86
|
* Selects stack using the given workspace and stack name. It returns an
|
|
@@ -102,12 +91,10 @@ class Stack {
|
|
|
102
91
|
* @param workspace
|
|
103
92
|
* The {@link Workspace} the stack will be created from.
|
|
104
93
|
*/
|
|
105
|
-
static select(name, workspace) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return stack;
|
|
110
|
-
});
|
|
94
|
+
static async select(name, workspace) {
|
|
95
|
+
const stack = new Stack(name, workspace, "select");
|
|
96
|
+
await stack.ready;
|
|
97
|
+
return stack;
|
|
111
98
|
}
|
|
112
99
|
/**
|
|
113
100
|
* Creates a new stack using the given workspace and stack name if the stack
|
|
@@ -119,38 +106,34 @@ class Stack {
|
|
|
119
106
|
* @param workspace
|
|
120
107
|
* The {@link Workspace} the stack will be created from.
|
|
121
108
|
*/
|
|
122
|
-
static createOrSelect(name, workspace) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
109
|
+
static async createOrSelect(name, workspace) {
|
|
110
|
+
const stack = new Stack(name, workspace, "createOrSelect");
|
|
111
|
+
await stack.ready;
|
|
112
|
+
return stack;
|
|
113
|
+
}
|
|
114
|
+
async readLines(logPath, callback) {
|
|
115
|
+
const eventLogTail = new tail_file_1.default(logPath, { startPos: 0, pollFileIntervalMs: 200 }).on("tail_error", (err) => {
|
|
116
|
+
throw err;
|
|
127
117
|
});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
event = JSON.parse(line);
|
|
140
|
-
callback(event);
|
|
141
|
-
}
|
|
142
|
-
catch (e) {
|
|
143
|
-
log.warn(`Failed to parse engine event
|
|
118
|
+
await eventLogTail.start();
|
|
119
|
+
const lineSplitter = readline.createInterface({ input: eventLogTail });
|
|
120
|
+
lineSplitter.on("line", (line) => {
|
|
121
|
+
let event;
|
|
122
|
+
try {
|
|
123
|
+
event = JSON.parse(line);
|
|
124
|
+
callback(event);
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
log.warn(`Failed to parse engine event
|
|
144
128
|
If you're seeing this warning, please comment on https://github.com/pulumi/pulumi/issues/6768 with the event and any
|
|
145
129
|
details about your environment.
|
|
146
130
|
Event: ${line}\n${e.toString()}`);
|
|
147
|
-
|
|
148
|
-
});
|
|
149
|
-
return {
|
|
150
|
-
tail: eventLogTail,
|
|
151
|
-
rl: lineSplitter,
|
|
152
|
-
};
|
|
131
|
+
}
|
|
153
132
|
});
|
|
133
|
+
return {
|
|
134
|
+
tail: eventLogTail,
|
|
135
|
+
rl: lineSplitter,
|
|
136
|
+
};
|
|
154
137
|
}
|
|
155
138
|
/**
|
|
156
139
|
* Creates or updates the resources in a stack by executing the program in
|
|
@@ -161,131 +144,129 @@ Event: ${line}\n${e.toString()}`);
|
|
|
161
144
|
*
|
|
162
145
|
* @see https://www.pulumi.com/docs/cli/commands/pulumi_up/
|
|
163
146
|
*/
|
|
164
|
-
up(opts) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (opts) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
args.push("--replace", rURN);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (opts.target) {
|
|
192
|
-
for (const tURN of opts.target) {
|
|
193
|
-
args.push("--target", tURN);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if (opts.policyPacks) {
|
|
197
|
-
for (const pack of opts.policyPacks) {
|
|
198
|
-
args.push("--policy-pack", pack);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
if (opts.policyPackConfigs) {
|
|
202
|
-
for (const packConfig of opts.policyPackConfigs) {
|
|
203
|
-
args.push("--policy-pack-config", packConfig);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (opts.targetDependents) {
|
|
207
|
-
args.push("--target-dependents");
|
|
208
|
-
}
|
|
209
|
-
if (opts.parallel) {
|
|
210
|
-
args.push("--parallel", opts.parallel.toString());
|
|
211
|
-
}
|
|
212
|
-
if (opts.userAgent) {
|
|
213
|
-
args.push("--exec-agent", opts.userAgent);
|
|
147
|
+
async up(opts) {
|
|
148
|
+
const args = ["up", "--yes", "--skip-preview"];
|
|
149
|
+
let kind = execKind.local;
|
|
150
|
+
let program = this.workspace.program;
|
|
151
|
+
args.push(...this.remoteArgs());
|
|
152
|
+
if (opts) {
|
|
153
|
+
if (opts.program) {
|
|
154
|
+
program = opts.program;
|
|
155
|
+
}
|
|
156
|
+
if (opts.message) {
|
|
157
|
+
args.push("--message", opts.message);
|
|
158
|
+
}
|
|
159
|
+
if (opts.expectNoChanges) {
|
|
160
|
+
args.push("--expect-no-changes");
|
|
161
|
+
}
|
|
162
|
+
if (opts.refresh) {
|
|
163
|
+
args.push("--refresh");
|
|
164
|
+
}
|
|
165
|
+
if (opts.diff) {
|
|
166
|
+
args.push("--diff");
|
|
167
|
+
}
|
|
168
|
+
if (opts.replace) {
|
|
169
|
+
for (const rURN of opts.replace) {
|
|
170
|
+
args.push("--replace", rURN);
|
|
214
171
|
}
|
|
215
|
-
|
|
216
|
-
|
|
172
|
+
}
|
|
173
|
+
if (opts.target) {
|
|
174
|
+
for (const tURN of opts.target) {
|
|
175
|
+
args.push("--target", tURN);
|
|
217
176
|
}
|
|
218
|
-
|
|
219
|
-
|
|
177
|
+
}
|
|
178
|
+
if (opts.policyPacks) {
|
|
179
|
+
for (const pack of opts.policyPacks) {
|
|
180
|
+
args.push("--policy-pack", pack);
|
|
220
181
|
}
|
|
221
|
-
|
|
222
|
-
|
|
182
|
+
}
|
|
183
|
+
if (opts.policyPackConfigs) {
|
|
184
|
+
for (const packConfig of opts.policyPackConfigs) {
|
|
185
|
+
args.push("--policy-pack-config", packConfig);
|
|
223
186
|
}
|
|
224
|
-
applyGlobalOpts(opts, args);
|
|
225
187
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
};
|
|
229
|
-
let didError = false;
|
|
230
|
-
if (program) {
|
|
231
|
-
kind = execKind.inline;
|
|
232
|
-
const server = new grpc.Server({
|
|
233
|
-
"grpc.max_receive_message_length": server_1.maxRPCMessageSize,
|
|
234
|
-
});
|
|
235
|
-
const languageServer = new server_1.LanguageServer(program);
|
|
236
|
-
server.addService(langrpc.LanguageRuntimeService, languageServer);
|
|
237
|
-
const port = yield new Promise((resolve, reject) => {
|
|
238
|
-
server.bindAsync(`127.0.0.1:0`, grpc.ServerCredentials.createInsecure(), (err, p) => {
|
|
239
|
-
if (err) {
|
|
240
|
-
reject(err);
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
resolve(p);
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
onExit = (hasError) => {
|
|
248
|
-
languageServer.onPulumiExit(hasError);
|
|
249
|
-
server.forceShutdown();
|
|
250
|
-
};
|
|
251
|
-
args.push(`--client=127.0.0.1:${port}`);
|
|
252
|
-
}
|
|
253
|
-
args.push("--exec-kind", kind);
|
|
254
|
-
let logPromise;
|
|
255
|
-
let logFile;
|
|
256
|
-
// Set up event log tailing
|
|
257
|
-
if (opts === null || opts === void 0 ? void 0 : opts.onEvent) {
|
|
258
|
-
const onEvent = opts.onEvent;
|
|
259
|
-
logFile = createLogFile("up");
|
|
260
|
-
args.push("--event-log", logFile);
|
|
261
|
-
logPromise = this.readLines(logFile, (event) => {
|
|
262
|
-
onEvent(event);
|
|
263
|
-
});
|
|
188
|
+
if (opts.targetDependents) {
|
|
189
|
+
args.push("--target-dependents");
|
|
264
190
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
upResult = yield this.runPulumiCmd(args, opts === null || opts === void 0 ? void 0 : opts.onOutput, opts === null || opts === void 0 ? void 0 : opts.signal);
|
|
191
|
+
if (opts.parallel) {
|
|
192
|
+
args.push("--parallel", opts.parallel.toString());
|
|
268
193
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
194
|
+
if (opts.userAgent) {
|
|
195
|
+
args.push("--exec-agent", opts.userAgent);
|
|
196
|
+
}
|
|
197
|
+
if (opts.plan) {
|
|
198
|
+
args.push("--plan", opts.plan);
|
|
199
|
+
}
|
|
200
|
+
if (opts.continueOnError) {
|
|
201
|
+
args.push("--continue-on-error");
|
|
202
|
+
}
|
|
203
|
+
if (opts.attachDebugger) {
|
|
204
|
+
args.push("--attach-debugger");
|
|
205
|
+
}
|
|
206
|
+
applyGlobalOpts(opts, args);
|
|
207
|
+
}
|
|
208
|
+
let onExit = (hasError) => {
|
|
209
|
+
return;
|
|
210
|
+
};
|
|
211
|
+
let didError = false;
|
|
212
|
+
if (program) {
|
|
213
|
+
kind = execKind.inline;
|
|
214
|
+
const server = new grpc.Server({
|
|
215
|
+
"grpc.max_receive_message_length": server_1.maxRPCMessageSize,
|
|
216
|
+
});
|
|
217
|
+
const languageServer = new server_1.LanguageServer(program);
|
|
218
|
+
server.addService(langrpc.LanguageRuntimeService, languageServer);
|
|
219
|
+
const port = await new Promise((resolve, reject) => {
|
|
220
|
+
server.bindAsync(`127.0.0.1:0`, grpc.ServerCredentials.createInsecure(), (err, p) => {
|
|
221
|
+
if (err) {
|
|
222
|
+
reject(err);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
resolve(p);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
onExit = (hasError) => {
|
|
230
|
+
languageServer.onPulumiExit(hasError);
|
|
231
|
+
server.forceShutdown();
|
|
287
232
|
};
|
|
288
|
-
|
|
233
|
+
args.push(`--client=127.0.0.1:${port}`);
|
|
234
|
+
}
|
|
235
|
+
args.push("--exec-kind", kind);
|
|
236
|
+
let logPromise;
|
|
237
|
+
let logFile;
|
|
238
|
+
// Set up event log tailing
|
|
239
|
+
if (opts?.onEvent) {
|
|
240
|
+
const onEvent = opts.onEvent;
|
|
241
|
+
logFile = createLogFile("up");
|
|
242
|
+
args.push("--event-log", logFile);
|
|
243
|
+
logPromise = this.readLines(logFile, (event) => {
|
|
244
|
+
onEvent(event);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
let upResult;
|
|
248
|
+
try {
|
|
249
|
+
upResult = await this.runPulumiCmd(args, opts?.onOutput, opts?.signal);
|
|
250
|
+
}
|
|
251
|
+
catch (e) {
|
|
252
|
+
didError = true;
|
|
253
|
+
throw e;
|
|
254
|
+
}
|
|
255
|
+
finally {
|
|
256
|
+
onExit(didError);
|
|
257
|
+
await cleanUp(logFile, await logPromise);
|
|
258
|
+
}
|
|
259
|
+
// TODO: do this in parallel after this is fixed https://github.com/pulumi/pulumi/issues/6050
|
|
260
|
+
const outputs = await this.outputs();
|
|
261
|
+
// If it's a remote workspace, explicitly set showSecrets to false to prevent attempting to
|
|
262
|
+
// load the project file.
|
|
263
|
+
const summary = await this.info(!this.isRemote && opts?.showSecrets);
|
|
264
|
+
return {
|
|
265
|
+
stdout: upResult.stdout,
|
|
266
|
+
stderr: upResult.stderr,
|
|
267
|
+
summary: summary,
|
|
268
|
+
outputs: outputs,
|
|
269
|
+
};
|
|
289
270
|
}
|
|
290
271
|
/**
|
|
291
272
|
* Performs a dry-run update to a stack, returning pending changes.
|
|
@@ -294,130 +275,128 @@ Event: ${line}\n${e.toString()}`);
|
|
|
294
275
|
*
|
|
295
276
|
* @see https://www.pulumi.com/docs/cli/commands/pulumi_preview/
|
|
296
277
|
*/
|
|
297
|
-
preview(opts) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if (opts) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
args.push("--replace", rURN);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
if (opts.target) {
|
|
325
|
-
for (const tURN of opts.target) {
|
|
326
|
-
args.push("--target", tURN);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
if (opts.policyPacks) {
|
|
330
|
-
for (const pack of opts.policyPacks) {
|
|
331
|
-
args.push("--policy-pack", pack);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (opts.policyPackConfigs) {
|
|
335
|
-
for (const packConfig of opts.policyPackConfigs) {
|
|
336
|
-
args.push("--policy-pack-config", packConfig);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
if (opts.targetDependents) {
|
|
340
|
-
args.push("--target-dependents");
|
|
341
|
-
}
|
|
342
|
-
if (opts.parallel) {
|
|
343
|
-
args.push("--parallel", opts.parallel.toString());
|
|
344
|
-
}
|
|
345
|
-
if (opts.userAgent) {
|
|
346
|
-
args.push("--exec-agent", opts.userAgent);
|
|
347
|
-
}
|
|
348
|
-
if (opts.plan) {
|
|
349
|
-
args.push("--save-plan", opts.plan);
|
|
350
|
-
}
|
|
351
|
-
if (opts.importFile) {
|
|
352
|
-
args.push("--import-file", opts.importFile);
|
|
278
|
+
async preview(opts) {
|
|
279
|
+
const args = ["preview"];
|
|
280
|
+
let kind = execKind.local;
|
|
281
|
+
let program = this.workspace.program;
|
|
282
|
+
args.push(...this.remoteArgs());
|
|
283
|
+
if (opts) {
|
|
284
|
+
if (opts.program) {
|
|
285
|
+
program = opts.program;
|
|
286
|
+
}
|
|
287
|
+
if (opts.message) {
|
|
288
|
+
args.push("--message", opts.message);
|
|
289
|
+
}
|
|
290
|
+
if (opts.expectNoChanges) {
|
|
291
|
+
args.push("--expect-no-changes");
|
|
292
|
+
}
|
|
293
|
+
if (opts.refresh) {
|
|
294
|
+
args.push("--refresh");
|
|
295
|
+
}
|
|
296
|
+
if (opts.diff) {
|
|
297
|
+
args.push("--diff");
|
|
298
|
+
}
|
|
299
|
+
if (opts.replace) {
|
|
300
|
+
for (const rURN of opts.replace) {
|
|
301
|
+
args.push("--replace", rURN);
|
|
353
302
|
}
|
|
354
|
-
|
|
355
|
-
|
|
303
|
+
}
|
|
304
|
+
if (opts.target) {
|
|
305
|
+
for (const tURN of opts.target) {
|
|
306
|
+
args.push("--target", tURN);
|
|
356
307
|
}
|
|
357
|
-
applyGlobalOpts(opts, args);
|
|
358
308
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
let didError = false;
|
|
363
|
-
if (program) {
|
|
364
|
-
kind = execKind.inline;
|
|
365
|
-
const server = new grpc.Server({
|
|
366
|
-
"grpc.max_receive_message_length": server_1.maxRPCMessageSize,
|
|
367
|
-
});
|
|
368
|
-
const languageServer = new server_1.LanguageServer(program);
|
|
369
|
-
server.addService(langrpc.LanguageRuntimeService, languageServer);
|
|
370
|
-
const port = yield new Promise((resolve, reject) => {
|
|
371
|
-
server.bindAsync(`127.0.0.1:0`, grpc.ServerCredentials.createInsecure(), (err, p) => {
|
|
372
|
-
if (err) {
|
|
373
|
-
reject(err);
|
|
374
|
-
}
|
|
375
|
-
else {
|
|
376
|
-
resolve(p);
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
|
-
onExit = (hasError) => {
|
|
381
|
-
languageServer.onPulumiExit(hasError);
|
|
382
|
-
server.forceShutdown();
|
|
383
|
-
};
|
|
384
|
-
args.push(`--client=127.0.0.1:${port}`);
|
|
385
|
-
}
|
|
386
|
-
args.push("--exec-kind", kind);
|
|
387
|
-
// Set up event log tailing
|
|
388
|
-
const logFile = createLogFile("preview");
|
|
389
|
-
args.push("--event-log", logFile);
|
|
390
|
-
let summaryEvent;
|
|
391
|
-
const logPromise = this.readLines(logFile, (event) => {
|
|
392
|
-
if (event.summaryEvent) {
|
|
393
|
-
summaryEvent = event.summaryEvent;
|
|
309
|
+
if (opts.policyPacks) {
|
|
310
|
+
for (const pack of opts.policyPacks) {
|
|
311
|
+
args.push("--policy-pack", pack);
|
|
394
312
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
313
|
+
}
|
|
314
|
+
if (opts.policyPackConfigs) {
|
|
315
|
+
for (const packConfig of opts.policyPackConfigs) {
|
|
316
|
+
args.push("--policy-pack-config", packConfig);
|
|
398
317
|
}
|
|
399
|
-
});
|
|
400
|
-
let previewResult;
|
|
401
|
-
try {
|
|
402
|
-
previewResult = yield this.runPulumiCmd(args, opts === null || opts === void 0 ? void 0 : opts.onOutput, opts === null || opts === void 0 ? void 0 : opts.signal);
|
|
403
318
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
throw e;
|
|
319
|
+
if (opts.targetDependents) {
|
|
320
|
+
args.push("--target-dependents");
|
|
407
321
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
yield cleanUp(logFile, yield logPromise);
|
|
322
|
+
if (opts.parallel) {
|
|
323
|
+
args.push("--parallel", opts.parallel.toString());
|
|
411
324
|
}
|
|
412
|
-
if (
|
|
413
|
-
|
|
325
|
+
if (opts.userAgent) {
|
|
326
|
+
args.push("--exec-agent", opts.userAgent);
|
|
414
327
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
328
|
+
if (opts.plan) {
|
|
329
|
+
args.push("--save-plan", opts.plan);
|
|
330
|
+
}
|
|
331
|
+
if (opts.importFile) {
|
|
332
|
+
args.push("--import-file", opts.importFile);
|
|
333
|
+
}
|
|
334
|
+
if (opts.attachDebugger) {
|
|
335
|
+
args.push("--attach-debugger");
|
|
336
|
+
}
|
|
337
|
+
applyGlobalOpts(opts, args);
|
|
338
|
+
}
|
|
339
|
+
let onExit = (hasError) => {
|
|
340
|
+
return;
|
|
341
|
+
};
|
|
342
|
+
let didError = false;
|
|
343
|
+
if (program) {
|
|
344
|
+
kind = execKind.inline;
|
|
345
|
+
const server = new grpc.Server({
|
|
346
|
+
"grpc.max_receive_message_length": server_1.maxRPCMessageSize,
|
|
347
|
+
});
|
|
348
|
+
const languageServer = new server_1.LanguageServer(program);
|
|
349
|
+
server.addService(langrpc.LanguageRuntimeService, languageServer);
|
|
350
|
+
const port = await new Promise((resolve, reject) => {
|
|
351
|
+
server.bindAsync(`127.0.0.1:0`, grpc.ServerCredentials.createInsecure(), (err, p) => {
|
|
352
|
+
if (err) {
|
|
353
|
+
reject(err);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
resolve(p);
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
onExit = (hasError) => {
|
|
361
|
+
languageServer.onPulumiExit(hasError);
|
|
362
|
+
server.forceShutdown();
|
|
419
363
|
};
|
|
364
|
+
args.push(`--client=127.0.0.1:${port}`);
|
|
365
|
+
}
|
|
366
|
+
args.push("--exec-kind", kind);
|
|
367
|
+
// Set up event log tailing
|
|
368
|
+
const logFile = createLogFile("preview");
|
|
369
|
+
args.push("--event-log", logFile);
|
|
370
|
+
let summaryEvent;
|
|
371
|
+
const logPromise = this.readLines(logFile, (event) => {
|
|
372
|
+
if (event.summaryEvent) {
|
|
373
|
+
summaryEvent = event.summaryEvent;
|
|
374
|
+
}
|
|
375
|
+
if (opts?.onEvent) {
|
|
376
|
+
const onEvent = opts.onEvent;
|
|
377
|
+
onEvent(event);
|
|
378
|
+
}
|
|
420
379
|
});
|
|
380
|
+
let previewResult;
|
|
381
|
+
try {
|
|
382
|
+
previewResult = await this.runPulumiCmd(args, opts?.onOutput, opts?.signal);
|
|
383
|
+
}
|
|
384
|
+
catch (e) {
|
|
385
|
+
didError = true;
|
|
386
|
+
throw e;
|
|
387
|
+
}
|
|
388
|
+
finally {
|
|
389
|
+
onExit(didError);
|
|
390
|
+
await cleanUp(logFile, await logPromise);
|
|
391
|
+
}
|
|
392
|
+
if (!summaryEvent) {
|
|
393
|
+
log.warn("Failed to parse summary event, but preview succeeded. PreviewResult `changeSummary` will be empty.");
|
|
394
|
+
}
|
|
395
|
+
return {
|
|
396
|
+
stdout: previewResult.stdout,
|
|
397
|
+
stderr: previewResult.stderr,
|
|
398
|
+
changeSummary: summaryEvent?.resourceChanges || {},
|
|
399
|
+
};
|
|
421
400
|
}
|
|
422
401
|
/**
|
|
423
402
|
* Compares the current stack’s resource state with the state known to exist
|
|
@@ -427,63 +406,61 @@ Event: ${line}\n${e.toString()}`);
|
|
|
427
406
|
* @param opts
|
|
428
407
|
* Options to customize the behavior of the refresh.
|
|
429
408
|
*/
|
|
430
|
-
refresh(opts) {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
if (opts) {
|
|
436
|
-
|
|
437
|
-
args.push("--message", opts.message);
|
|
438
|
-
}
|
|
439
|
-
if (opts.expectNoChanges) {
|
|
440
|
-
args.push("--expect-no-changes");
|
|
441
|
-
}
|
|
442
|
-
if (opts.clearPendingCreates) {
|
|
443
|
-
args.push("--clear-pending-creates");
|
|
444
|
-
}
|
|
445
|
-
if (opts.target) {
|
|
446
|
-
for (const tURN of opts.target) {
|
|
447
|
-
args.push("--target", tURN);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
if (opts.parallel) {
|
|
451
|
-
args.push("--parallel", opts.parallel.toString());
|
|
452
|
-
}
|
|
453
|
-
if (opts.userAgent) {
|
|
454
|
-
args.push("--exec-agent", opts.userAgent);
|
|
455
|
-
}
|
|
456
|
-
applyGlobalOpts(opts, args);
|
|
409
|
+
async refresh(opts) {
|
|
410
|
+
const args = ["refresh", "--yes"];
|
|
411
|
+
args.push(opts?.previewOnly ? "--preview-only" : "--skip-preview");
|
|
412
|
+
args.push(...this.remoteArgs());
|
|
413
|
+
if (opts) {
|
|
414
|
+
if (opts.message) {
|
|
415
|
+
args.push("--message", opts.message);
|
|
457
416
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
// Set up event log tailing
|
|
461
|
-
if (opts === null || opts === void 0 ? void 0 : opts.onEvent) {
|
|
462
|
-
const onEvent = opts.onEvent;
|
|
463
|
-
logFile = createLogFile("refresh");
|
|
464
|
-
args.push("--event-log", logFile);
|
|
465
|
-
logPromise = this.readLines(logFile, (event) => {
|
|
466
|
-
onEvent(event);
|
|
467
|
-
});
|
|
417
|
+
if (opts.expectNoChanges) {
|
|
418
|
+
args.push("--expect-no-changes");
|
|
468
419
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
let refResult;
|
|
472
|
-
try {
|
|
473
|
-
refResult = yield this.runPulumiCmd(args, opts === null || opts === void 0 ? void 0 : opts.onOutput, opts === null || opts === void 0 ? void 0 : opts.signal);
|
|
420
|
+
if (opts.clearPendingCreates) {
|
|
421
|
+
args.push("--clear-pending-creates");
|
|
474
422
|
}
|
|
475
|
-
|
|
476
|
-
|
|
423
|
+
if (opts.target) {
|
|
424
|
+
for (const tURN of opts.target) {
|
|
425
|
+
args.push("--target", tURN);
|
|
426
|
+
}
|
|
477
427
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
428
|
+
if (opts.parallel) {
|
|
429
|
+
args.push("--parallel", opts.parallel.toString());
|
|
430
|
+
}
|
|
431
|
+
if (opts.userAgent) {
|
|
432
|
+
args.push("--exec-agent", opts.userAgent);
|
|
433
|
+
}
|
|
434
|
+
applyGlobalOpts(opts, args);
|
|
435
|
+
}
|
|
436
|
+
let logPromise;
|
|
437
|
+
let logFile;
|
|
438
|
+
// Set up event log tailing
|
|
439
|
+
if (opts?.onEvent) {
|
|
440
|
+
const onEvent = opts.onEvent;
|
|
441
|
+
logFile = createLogFile("refresh");
|
|
442
|
+
args.push("--event-log", logFile);
|
|
443
|
+
logPromise = this.readLines(logFile, (event) => {
|
|
444
|
+
onEvent(event);
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
const kind = this.workspace.program ? execKind.inline : execKind.local;
|
|
448
|
+
args.push("--exec-kind", kind);
|
|
449
|
+
let refResult;
|
|
450
|
+
try {
|
|
451
|
+
refResult = await this.runPulumiCmd(args, opts?.onOutput, opts?.signal);
|
|
452
|
+
}
|
|
453
|
+
finally {
|
|
454
|
+
await cleanUp(logFile, await logPromise);
|
|
455
|
+
}
|
|
456
|
+
// If it's a remote workspace, explicitly set showSecrets to false to prevent attempting to
|
|
457
|
+
// load the project file.
|
|
458
|
+
const summary = await this.info(!this.isRemote && opts?.showSecrets);
|
|
459
|
+
return {
|
|
460
|
+
stdout: refResult.stdout,
|
|
461
|
+
stderr: refResult.stderr,
|
|
462
|
+
summary: summary,
|
|
463
|
+
};
|
|
487
464
|
}
|
|
488
465
|
/**
|
|
489
466
|
* Deletes all resources in a stack. By default, this method will leave all
|
|
@@ -493,180 +470,174 @@ Event: ${line}\n${e.toString()}`);
|
|
|
493
470
|
* @param opts
|
|
494
471
|
* Options to customize the behavior of the destroy.
|
|
495
472
|
*/
|
|
496
|
-
destroy(opts) {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
473
|
+
async destroy(opts) {
|
|
474
|
+
const args = ["destroy"];
|
|
475
|
+
if (opts?.previewOnly) {
|
|
476
|
+
args.push("--preview-only");
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
args.push("--yes", "--skip-preview");
|
|
480
|
+
}
|
|
481
|
+
args.push(...this.remoteArgs());
|
|
482
|
+
if (opts) {
|
|
483
|
+
if (opts.message) {
|
|
484
|
+
args.push("--message", opts.message);
|
|
504
485
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
args.push("--message", opts.message);
|
|
509
|
-
}
|
|
510
|
-
if (opts.target) {
|
|
511
|
-
for (const tURN of opts.target) {
|
|
512
|
-
args.push("--target", tURN);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
if (opts.targetDependents) {
|
|
516
|
-
args.push("--target-dependents");
|
|
517
|
-
}
|
|
518
|
-
if (opts.excludeProtected) {
|
|
519
|
-
args.push("--exclude-protected");
|
|
520
|
-
}
|
|
521
|
-
if (opts.continueOnError) {
|
|
522
|
-
args.push("--continue-on-error");
|
|
486
|
+
if (opts.target) {
|
|
487
|
+
for (const tURN of opts.target) {
|
|
488
|
+
args.push("--target", tURN);
|
|
523
489
|
}
|
|
524
|
-
if (opts.parallel) {
|
|
525
|
-
args.push("--parallel", opts.parallel.toString());
|
|
526
|
-
}
|
|
527
|
-
if (opts.userAgent) {
|
|
528
|
-
args.push("--exec-agent", opts.userAgent);
|
|
529
|
-
}
|
|
530
|
-
if (opts.refresh) {
|
|
531
|
-
args.push("--refresh");
|
|
532
|
-
}
|
|
533
|
-
applyGlobalOpts(opts, args);
|
|
534
490
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
// Set up event log tailing
|
|
538
|
-
if (opts === null || opts === void 0 ? void 0 : opts.onEvent) {
|
|
539
|
-
const onEvent = opts.onEvent;
|
|
540
|
-
logFile = createLogFile("destroy");
|
|
541
|
-
args.push("--event-log", logFile);
|
|
542
|
-
logPromise = this.readLines(logFile, (event) => {
|
|
543
|
-
onEvent(event);
|
|
544
|
-
});
|
|
491
|
+
if (opts.targetDependents) {
|
|
492
|
+
args.push("--target-dependents");
|
|
545
493
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
let desResult;
|
|
549
|
-
try {
|
|
550
|
-
desResult = yield this.runPulumiCmd(args, opts === null || opts === void 0 ? void 0 : opts.onOutput, opts === null || opts === void 0 ? void 0 : opts.signal);
|
|
494
|
+
if (opts.excludeProtected) {
|
|
495
|
+
args.push("--exclude-protected");
|
|
551
496
|
}
|
|
552
|
-
|
|
553
|
-
|
|
497
|
+
if (opts.continueOnError) {
|
|
498
|
+
args.push("--continue-on-error");
|
|
554
499
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const summary = yield this.info(!this.isRemote && (opts === null || opts === void 0 ? void 0 : opts.showSecrets));
|
|
558
|
-
// If `opts.remove` was set, remove the stack now. We take this approach
|
|
559
|
-
// rather than passing `--remove` to `pulumi destroy` because the latter
|
|
560
|
-
// would make it impossible for us to retrieve a summary of the
|
|
561
|
-
// operation above for returning to the caller.
|
|
562
|
-
if (opts === null || opts === void 0 ? void 0 : opts.remove) {
|
|
563
|
-
yield this.workspace.removeStack(this.name);
|
|
500
|
+
if (opts.parallel) {
|
|
501
|
+
args.push("--parallel", opts.parallel.toString());
|
|
564
502
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
503
|
+
if (opts.userAgent) {
|
|
504
|
+
args.push("--exec-agent", opts.userAgent);
|
|
505
|
+
}
|
|
506
|
+
if (opts.refresh) {
|
|
507
|
+
args.push("--refresh");
|
|
508
|
+
}
|
|
509
|
+
applyGlobalOpts(opts, args);
|
|
510
|
+
}
|
|
511
|
+
let logPromise;
|
|
512
|
+
let logFile;
|
|
513
|
+
// Set up event log tailing
|
|
514
|
+
if (opts?.onEvent) {
|
|
515
|
+
const onEvent = opts.onEvent;
|
|
516
|
+
logFile = createLogFile("destroy");
|
|
517
|
+
args.push("--event-log", logFile);
|
|
518
|
+
logPromise = this.readLines(logFile, (event) => {
|
|
519
|
+
onEvent(event);
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
const kind = this.workspace.program ? execKind.inline : execKind.local;
|
|
523
|
+
args.push("--exec-kind", kind);
|
|
524
|
+
let desResult;
|
|
525
|
+
try {
|
|
526
|
+
desResult = await this.runPulumiCmd(args, opts?.onOutput, opts?.signal);
|
|
527
|
+
}
|
|
528
|
+
finally {
|
|
529
|
+
await cleanUp(logFile, await logPromise);
|
|
530
|
+
}
|
|
531
|
+
// If it's a remote workspace, explicitly set showSecrets to false to prevent attempting to
|
|
532
|
+
// load the project file.
|
|
533
|
+
const summary = await this.info(!this.isRemote && opts?.showSecrets);
|
|
534
|
+
// If `opts.remove` was set, remove the stack now. We take this approach
|
|
535
|
+
// rather than passing `--remove` to `pulumi destroy` because the latter
|
|
536
|
+
// would make it impossible for us to retrieve a summary of the
|
|
537
|
+
// operation above for returning to the caller.
|
|
538
|
+
if (opts?.remove) {
|
|
539
|
+
await this.workspace.removeStack(this.name);
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
stdout: desResult.stdout,
|
|
543
|
+
stderr: desResult.stderr,
|
|
544
|
+
summary: summary,
|
|
545
|
+
};
|
|
571
546
|
}
|
|
572
547
|
/**
|
|
573
548
|
* Rename an existing stack
|
|
574
549
|
*/
|
|
575
|
-
rename(options) {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
};
|
|
590
|
-
});
|
|
550
|
+
async rename(options) {
|
|
551
|
+
const args = ["stack", "rename", options.stackName];
|
|
552
|
+
args.push(...this.remoteArgs());
|
|
553
|
+
applyGlobalOpts(options, args);
|
|
554
|
+
const renameResult = await this.runPulumiCmd(args, options?.onOutput, options?.signal);
|
|
555
|
+
if (this.isRemote && options?.showSecrets) {
|
|
556
|
+
throw new Error("can't enable `showSecrets` for remote workspaces");
|
|
557
|
+
}
|
|
558
|
+
const summary = await this.info(!this.isRemote && options?.showSecrets);
|
|
559
|
+
return {
|
|
560
|
+
stdout: renameResult.stdout,
|
|
561
|
+
stderr: renameResult.stderr,
|
|
562
|
+
summary: summary,
|
|
563
|
+
};
|
|
591
564
|
}
|
|
592
565
|
/**
|
|
593
566
|
* Import resources into the stack
|
|
594
567
|
*
|
|
595
568
|
* @param options Options to specify resources and customize the behavior of the import.
|
|
596
569
|
*/
|
|
597
|
-
import(options) {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
args.push("--generate-code=false");
|
|
627
|
-
}
|
|
628
|
-
else {
|
|
629
|
-
args.push("--out", tempGeneratedCodeFile);
|
|
630
|
-
}
|
|
631
|
-
if (options.protect === false) {
|
|
632
|
-
// --protect is set to true by default
|
|
633
|
-
// only use --protect=false if the user explicitly sets it to false
|
|
634
|
-
args.push(`--protect=false`);
|
|
635
|
-
}
|
|
636
|
-
if (options.converter) {
|
|
637
|
-
// if the user specifies a converter, pass it to `--from <converter>` argument of import
|
|
638
|
-
args.push("--from", options.converter);
|
|
639
|
-
if (options.converterArgs) {
|
|
640
|
-
// pass any additional arguments to the converter
|
|
641
|
-
// for example using {
|
|
642
|
-
// converter: "terraform"
|
|
643
|
-
// converterArgs: "./tfstate.json"
|
|
644
|
-
// }
|
|
645
|
-
// would be equivalent to `pulumi import --from terraform ./tfstate.json`
|
|
646
|
-
args.push("--");
|
|
647
|
-
args.push(...options.converterArgs);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
importResult = yield this.runPulumiCmd(args, options.onOutput);
|
|
651
|
-
const summary = yield this.info(!this.isRemote && options.showSecrets);
|
|
652
|
-
let generatedCode = "";
|
|
653
|
-
if (options.generateCode !== false) {
|
|
654
|
-
generatedCode = yield fs.promises.readFile(tempGeneratedCodeFile, "utf8");
|
|
655
|
-
}
|
|
656
|
-
return {
|
|
657
|
-
stdout: importResult.stdout,
|
|
658
|
-
stderr: importResult.stderr,
|
|
659
|
-
generatedCode: generatedCode,
|
|
660
|
-
summary: summary,
|
|
661
|
-
};
|
|
662
|
-
}
|
|
663
|
-
finally {
|
|
664
|
-
if (tempDir !== "") {
|
|
665
|
-
// clean up temp directory we used for the import file
|
|
666
|
-
yield fs.promises.rm(tempDir, { recursive: true });
|
|
667
|
-
}
|
|
570
|
+
async import(options) {
|
|
571
|
+
const args = ["import", "--yes", "--skip-preview"];
|
|
572
|
+
if (options.message) {
|
|
573
|
+
args.push("--message", options.message);
|
|
574
|
+
}
|
|
575
|
+
applyGlobalOpts(options, args);
|
|
576
|
+
let importResult;
|
|
577
|
+
// for import operations, generate a temporary directory to store the following:
|
|
578
|
+
// - the import file when the user specifies resources to import
|
|
579
|
+
// - the output file for the generated code
|
|
580
|
+
// we use the import file as input to the import command
|
|
581
|
+
// we the output file to read the generated code and return it to the user
|
|
582
|
+
let tempDir = "";
|
|
583
|
+
try {
|
|
584
|
+
tempDir = await fs.promises.mkdtemp(pathlib.join(os.tmpdir(), "pulumi-import-"));
|
|
585
|
+
const tempGeneratedCodeFile = pathlib.join(tempDir, "generated-code.txt");
|
|
586
|
+
if (options.resources) {
|
|
587
|
+
// user has specified resources to import, write them to a temp import file
|
|
588
|
+
const tempImportFile = pathlib.join(tempDir, "import.json");
|
|
589
|
+
await fs.promises.writeFile(tempImportFile, JSON.stringify({
|
|
590
|
+
nameTable: options.nameTable,
|
|
591
|
+
resources: options.resources,
|
|
592
|
+
}));
|
|
593
|
+
args.push("--file", tempImportFile);
|
|
594
|
+
}
|
|
595
|
+
if (options.generateCode === false) {
|
|
596
|
+
// --generate-code is set to true by default
|
|
597
|
+
// only use --generate-code=false if the user explicitly sets it to false
|
|
598
|
+
args.push("--generate-code=false");
|
|
668
599
|
}
|
|
669
|
-
|
|
600
|
+
else {
|
|
601
|
+
args.push("--out", tempGeneratedCodeFile);
|
|
602
|
+
}
|
|
603
|
+
if (options.protect === false) {
|
|
604
|
+
// --protect is set to true by default
|
|
605
|
+
// only use --protect=false if the user explicitly sets it to false
|
|
606
|
+
args.push(`--protect=false`);
|
|
607
|
+
}
|
|
608
|
+
if (options.converter) {
|
|
609
|
+
// if the user specifies a converter, pass it to `--from <converter>` argument of import
|
|
610
|
+
args.push("--from", options.converter);
|
|
611
|
+
if (options.converterArgs) {
|
|
612
|
+
// pass any additional arguments to the converter
|
|
613
|
+
// for example using {
|
|
614
|
+
// converter: "terraform"
|
|
615
|
+
// converterArgs: "./tfstate.json"
|
|
616
|
+
// }
|
|
617
|
+
// would be equivalent to `pulumi import --from terraform ./tfstate.json`
|
|
618
|
+
args.push("--");
|
|
619
|
+
args.push(...options.converterArgs);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
importResult = await this.runPulumiCmd(args, options.onOutput);
|
|
623
|
+
const summary = await this.info(!this.isRemote && options.showSecrets);
|
|
624
|
+
let generatedCode = "";
|
|
625
|
+
if (options.generateCode !== false) {
|
|
626
|
+
generatedCode = await fs.promises.readFile(tempGeneratedCodeFile, "utf8");
|
|
627
|
+
}
|
|
628
|
+
return {
|
|
629
|
+
stdout: importResult.stdout,
|
|
630
|
+
stderr: importResult.stderr,
|
|
631
|
+
generatedCode: generatedCode,
|
|
632
|
+
summary: summary,
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
finally {
|
|
636
|
+
if (tempDir !== "") {
|
|
637
|
+
// clean up temp directory we used for the import file
|
|
638
|
+
await fs.promises.rm(tempDir, { recursive: true });
|
|
639
|
+
}
|
|
640
|
+
}
|
|
670
641
|
}
|
|
671
642
|
/**
|
|
672
643
|
* Adds environments to the end of a stack's import list. Imported
|
|
@@ -677,18 +648,14 @@ Event: ${line}\n${e.toString()}`);
|
|
|
677
648
|
* @param environments
|
|
678
649
|
* The names of the environments to add to the stack's configuration
|
|
679
650
|
*/
|
|
680
|
-
addEnvironments(...environments) {
|
|
681
|
-
|
|
682
|
-
yield this.workspace.addEnvironments(this.name, ...environments);
|
|
683
|
-
});
|
|
651
|
+
async addEnvironments(...environments) {
|
|
652
|
+
await this.workspace.addEnvironments(this.name, ...environments);
|
|
684
653
|
}
|
|
685
654
|
/**
|
|
686
655
|
* Returns the list of environments currently in the stack's import list.
|
|
687
656
|
*/
|
|
688
|
-
listEnvironments() {
|
|
689
|
-
return
|
|
690
|
-
return this.workspace.listEnvironments(this.name);
|
|
691
|
-
});
|
|
657
|
+
async listEnvironments() {
|
|
658
|
+
return this.workspace.listEnvironments(this.name);
|
|
692
659
|
}
|
|
693
660
|
/**
|
|
694
661
|
* Removes an environment from a stack's import list.
|
|
@@ -696,10 +663,8 @@ Event: ${line}\n${e.toString()}`);
|
|
|
696
663
|
* @param environment
|
|
697
664
|
* The name of the environment to remove from the stack's configuration
|
|
698
665
|
*/
|
|
699
|
-
removeEnvironment(environment) {
|
|
700
|
-
|
|
701
|
-
yield this.workspace.removeEnvironment(this.name, environment);
|
|
702
|
-
});
|
|
666
|
+
async removeEnvironment(environment) {
|
|
667
|
+
await this.workspace.removeEnvironment(this.name, environment);
|
|
703
668
|
}
|
|
704
669
|
/**
|
|
705
670
|
* Returns the config value associated with the specified key.
|
|
@@ -709,18 +674,14 @@ Event: ${line}\n${e.toString()}`);
|
|
|
709
674
|
* @param path
|
|
710
675
|
* The key contains a path to a property in a map or list to get
|
|
711
676
|
*/
|
|
712
|
-
getConfig(key, path) {
|
|
713
|
-
return
|
|
714
|
-
return this.workspace.getConfig(this.name, key, path);
|
|
715
|
-
});
|
|
677
|
+
async getConfig(key, path) {
|
|
678
|
+
return this.workspace.getConfig(this.name, key, path);
|
|
716
679
|
}
|
|
717
680
|
/**
|
|
718
681
|
* Returns the full config map associated with the stack in the workspace.
|
|
719
682
|
*/
|
|
720
|
-
getAllConfig() {
|
|
721
|
-
return
|
|
722
|
-
return this.workspace.getAllConfig(this.name);
|
|
723
|
-
});
|
|
683
|
+
async getAllConfig() {
|
|
684
|
+
return this.workspace.getAllConfig(this.name);
|
|
724
685
|
}
|
|
725
686
|
/**
|
|
726
687
|
* Sets a config key-value pair on the stack in the associated Workspace.
|
|
@@ -732,10 +693,8 @@ Event: ${line}\n${e.toString()}`);
|
|
|
732
693
|
* @param path
|
|
733
694
|
* The key contains a path to a property in a map or list to set.
|
|
734
695
|
*/
|
|
735
|
-
setConfig(key, value, path) {
|
|
736
|
-
return
|
|
737
|
-
return this.workspace.setConfig(this.name, key, value, path);
|
|
738
|
-
});
|
|
696
|
+
async setConfig(key, value, path) {
|
|
697
|
+
return this.workspace.setConfig(this.name, key, value, path);
|
|
739
698
|
}
|
|
740
699
|
/**
|
|
741
700
|
* Sets all specified config values on the stack in the associated
|
|
@@ -746,10 +705,8 @@ Event: ${line}\n${e.toString()}`);
|
|
|
746
705
|
* @param path
|
|
747
706
|
* The keys contain a path to a property in a map or list to set.
|
|
748
707
|
*/
|
|
749
|
-
setAllConfig(config, path) {
|
|
750
|
-
return
|
|
751
|
-
return this.workspace.setAllConfig(this.name, config, path);
|
|
752
|
-
});
|
|
708
|
+
async setAllConfig(config, path) {
|
|
709
|
+
return this.workspace.setAllConfig(this.name, config, path);
|
|
753
710
|
}
|
|
754
711
|
/**
|
|
755
712
|
* Removes the specified config key from the stack in the associated workspace.
|
|
@@ -759,10 +716,8 @@ Event: ${line}\n${e.toString()}`);
|
|
|
759
716
|
* @param path
|
|
760
717
|
* The key contains a path to a property in a map or list to remove.
|
|
761
718
|
*/
|
|
762
|
-
removeConfig(key, path) {
|
|
763
|
-
return
|
|
764
|
-
return this.workspace.removeConfig(this.name, key, path);
|
|
765
|
-
});
|
|
719
|
+
async removeConfig(key, path) {
|
|
720
|
+
return this.workspace.removeConfig(this.name, key, path);
|
|
766
721
|
}
|
|
767
722
|
/**
|
|
768
723
|
* Removes the specified config keys from the stack in the associated workspace.
|
|
@@ -772,28 +727,22 @@ Event: ${line}\n${e.toString()}`);
|
|
|
772
727
|
* @param path
|
|
773
728
|
* The keys contain a path to a property in a map or list to remove.
|
|
774
729
|
*/
|
|
775
|
-
removeAllConfig(keys, path) {
|
|
776
|
-
return
|
|
777
|
-
return this.workspace.removeAllConfig(this.name, keys, path);
|
|
778
|
-
});
|
|
730
|
+
async removeAllConfig(keys, path) {
|
|
731
|
+
return this.workspace.removeAllConfig(this.name, keys, path);
|
|
779
732
|
}
|
|
780
733
|
/**
|
|
781
734
|
* Gets and sets the config map used with the last update.
|
|
782
735
|
*/
|
|
783
|
-
refreshConfig() {
|
|
784
|
-
return
|
|
785
|
-
return this.workspace.refreshConfig(this.name);
|
|
786
|
-
});
|
|
736
|
+
async refreshConfig() {
|
|
737
|
+
return this.workspace.refreshConfig(this.name);
|
|
787
738
|
}
|
|
788
739
|
/**
|
|
789
740
|
* Returns the tag value associated with specified key.
|
|
790
741
|
*
|
|
791
742
|
* @param key The key to use for the tag lookup.
|
|
792
743
|
*/
|
|
793
|
-
getTag(key) {
|
|
794
|
-
return
|
|
795
|
-
return this.workspace.getTag(this.name, key);
|
|
796
|
-
});
|
|
744
|
+
async getTag(key) {
|
|
745
|
+
return this.workspace.getTag(this.name, key);
|
|
797
746
|
}
|
|
798
747
|
/**
|
|
799
748
|
* Sets a tag key-value pair on the stack in the associated workspace.
|
|
@@ -803,10 +752,8 @@ Event: ${line}\n${e.toString()}`);
|
|
|
803
752
|
* @param value
|
|
804
753
|
* The tag value to set.
|
|
805
754
|
*/
|
|
806
|
-
setTag(key, value) {
|
|
807
|
-
|
|
808
|
-
yield this.workspace.setTag(this.name, key, value);
|
|
809
|
-
});
|
|
755
|
+
async setTag(key, value) {
|
|
756
|
+
await this.workspace.setTag(this.name, key, value);
|
|
810
757
|
}
|
|
811
758
|
/**
|
|
812
759
|
* Removes the specified tag key-value pair from the stack in the associated
|
|
@@ -814,81 +761,67 @@ Event: ${line}\n${e.toString()}`);
|
|
|
814
761
|
*
|
|
815
762
|
* @param key The tag key to remove.
|
|
816
763
|
*/
|
|
817
|
-
removeTag(key) {
|
|
818
|
-
|
|
819
|
-
yield this.workspace.removeTag(this.name, key);
|
|
820
|
-
});
|
|
764
|
+
async removeTag(key) {
|
|
765
|
+
await this.workspace.removeTag(this.name, key);
|
|
821
766
|
}
|
|
822
767
|
/**
|
|
823
768
|
* Returns the full tag map associated with the stack in the workspace.
|
|
824
769
|
*/
|
|
825
|
-
listTags() {
|
|
826
|
-
return
|
|
827
|
-
return this.workspace.listTags(this.name);
|
|
828
|
-
});
|
|
770
|
+
async listTags() {
|
|
771
|
+
return this.workspace.listTags(this.name);
|
|
829
772
|
}
|
|
830
773
|
/**
|
|
831
774
|
* Gets the current set of stack outputs from the last {@link Stack.up}.
|
|
832
775
|
*/
|
|
833
|
-
outputs() {
|
|
834
|
-
return
|
|
835
|
-
return this.workspace.stackOutputs(this.name);
|
|
836
|
-
});
|
|
776
|
+
async outputs() {
|
|
777
|
+
return this.workspace.stackOutputs(this.name);
|
|
837
778
|
}
|
|
838
779
|
/**
|
|
839
780
|
* Returns a list summarizing all previous and current results from Stack
|
|
840
781
|
* lifecycle operations (up/preview/refresh/destroy).
|
|
841
782
|
*/
|
|
842
|
-
history(pageSize, page, showSecrets) {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
if (
|
|
849
|
-
|
|
850
|
-
page = 1;
|
|
851
|
-
}
|
|
852
|
-
args.push("--page-size", Math.floor(pageSize).toString(), "--page", Math.floor(page).toString());
|
|
783
|
+
async history(pageSize, page, showSecrets) {
|
|
784
|
+
const args = ["stack", "history", "--json"];
|
|
785
|
+
if (showSecrets ?? true) {
|
|
786
|
+
args.push("--show-secrets");
|
|
787
|
+
}
|
|
788
|
+
if (pageSize) {
|
|
789
|
+
if (!page || page < 1) {
|
|
790
|
+
page = 1;
|
|
853
791
|
}
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
return value;
|
|
860
|
-
});
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
info(showSecrets) {
|
|
864
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
865
|
-
const history = yield this.history(1 /*pageSize*/, undefined, showSecrets);
|
|
866
|
-
if (!history || history.length === 0) {
|
|
867
|
-
return undefined;
|
|
792
|
+
args.push("--page-size", Math.floor(pageSize).toString(), "--page", Math.floor(page).toString());
|
|
793
|
+
}
|
|
794
|
+
const result = await this.runPulumiCmd(args);
|
|
795
|
+
return JSON.parse(result.stdout, (key, value) => {
|
|
796
|
+
if (key === "startTime" || key === "endTime") {
|
|
797
|
+
return new Date(value);
|
|
868
798
|
}
|
|
869
|
-
return
|
|
799
|
+
return value;
|
|
870
800
|
});
|
|
871
801
|
}
|
|
802
|
+
async info(showSecrets) {
|
|
803
|
+
const history = await this.history(1 /*pageSize*/, undefined, showSecrets);
|
|
804
|
+
if (!history || history.length === 0) {
|
|
805
|
+
return undefined;
|
|
806
|
+
}
|
|
807
|
+
return history[0];
|
|
808
|
+
}
|
|
872
809
|
/**
|
|
873
810
|
* Stops a stack's currently running update. It returns an error if no
|
|
874
811
|
* update is currently running. Note that this operation is _very
|
|
875
812
|
* dangerous_, and may leave the stack in an inconsistent state if a
|
|
876
813
|
* resource operation was pending when the update was canceled.
|
|
877
814
|
*/
|
|
878
|
-
cancel() {
|
|
879
|
-
|
|
880
|
-
yield this.runPulumiCmd(["cancel", "--yes"]);
|
|
881
|
-
});
|
|
815
|
+
async cancel() {
|
|
816
|
+
await this.runPulumiCmd(["cancel", "--yes"]);
|
|
882
817
|
}
|
|
883
818
|
/**
|
|
884
819
|
* Exports the deployment state of the stack. This can be combined with
|
|
885
820
|
* {@link Stack.importStack} to edit a stack's state (such as recovery from
|
|
886
821
|
* failed deployments).
|
|
887
822
|
*/
|
|
888
|
-
exportStack() {
|
|
889
|
-
return
|
|
890
|
-
return this.workspace.exportStack(this.name);
|
|
891
|
-
});
|
|
823
|
+
async exportStack() {
|
|
824
|
+
return this.workspace.exportStack(this.name);
|
|
892
825
|
}
|
|
893
826
|
/**
|
|
894
827
|
* Imports the specified deployment state into a pre-existing stack. This
|
|
@@ -898,30 +831,26 @@ Event: ${line}\n${e.toString()}`);
|
|
|
898
831
|
* @param state
|
|
899
832
|
* The stack state to import.
|
|
900
833
|
*/
|
|
901
|
-
importStack(state) {
|
|
902
|
-
return
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
const result = yield this.workspace.pulumiCommand.run(args, this.workspace.workDir, envs, onOutput, signal);
|
|
922
|
-
yield this.workspace.postCommandCallback(this.name);
|
|
923
|
-
return result;
|
|
924
|
-
});
|
|
834
|
+
async importStack(state) {
|
|
835
|
+
return this.workspace.importStack(this.name, state);
|
|
836
|
+
}
|
|
837
|
+
async runPulumiCmd(args, onOutput, signal) {
|
|
838
|
+
let envs = {
|
|
839
|
+
PULUMI_DEBUG_COMMANDS: "true",
|
|
840
|
+
};
|
|
841
|
+
if (this.isRemote) {
|
|
842
|
+
envs["PULUMI_EXPERIMENTAL"] = "true";
|
|
843
|
+
}
|
|
844
|
+
const pulumiHome = this.workspace.pulumiHome;
|
|
845
|
+
if (pulumiHome) {
|
|
846
|
+
envs["PULUMI_HOME"] = pulumiHome;
|
|
847
|
+
}
|
|
848
|
+
envs = { ...envs, ...this.workspace.envVars };
|
|
849
|
+
const additionalArgs = await this.workspace.serializeArgsForOp(this.name);
|
|
850
|
+
args = [...args, "--stack", this.name, ...additionalArgs];
|
|
851
|
+
const result = await this.workspace.pulumiCommand.run(args, this.workspace.workDir, envs, onOutput, signal);
|
|
852
|
+
await this.workspace.postCommandCallback(this.name);
|
|
853
|
+
return result;
|
|
925
854
|
}
|
|
926
855
|
get isRemote() {
|
|
927
856
|
const ws = this.workspace;
|
|
@@ -995,10 +924,10 @@ const createLogFile = (command) => {
|
|
|
995
924
|
fs.closeSync(fs.openSync(logFile, "w"));
|
|
996
925
|
return logFile;
|
|
997
926
|
};
|
|
998
|
-
const cleanUp = (logFile, rl) =>
|
|
927
|
+
const cleanUp = async (logFile, rl) => {
|
|
999
928
|
if (rl) {
|
|
1000
929
|
// stop tailing
|
|
1001
|
-
|
|
930
|
+
await rl.tail.quit();
|
|
1002
931
|
// close the readline interface
|
|
1003
932
|
rl.rl.close();
|
|
1004
933
|
}
|
|
@@ -1017,5 +946,5 @@ const cleanUp = (logFile, rl) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
1017
946
|
});
|
|
1018
947
|
}
|
|
1019
948
|
}
|
|
1020
|
-
}
|
|
949
|
+
};
|
|
1021
950
|
//# sourceMappingURL=stack.js.map
|