@pulumi/pulumi 3.135.2-alpha.xaa9ca8a → 3.136.0-alpha.xbd76b17

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.
Files changed (177) hide show
  1. package/package.json +1 -1
  2. package/version.d.ts +1 -1
  3. package/version.js +1 -1
  4. package/npm/testdata/nested/project/index.d.ts +0 -0
  5. package/npm/testdata/nested/project/index.js +0 -16
  6. package/npm/testdata/nested/project/index.js.map +0 -1
  7. package/tests/automation/cmd.spec.d.ts +0 -1
  8. package/tests/automation/cmd.spec.js +0 -186
  9. package/tests/automation/cmd.spec.js.map +0 -1
  10. package/tests/automation/data/correct_project/Pulumi.yaml +0 -3
  11. package/tests/automation/data/import/Pulumi.yaml +0 -2
  12. package/tests/automation/data/import/expected_generated_code.txt +0 -11
  13. package/tests/automation/data/json/Pulumi.dev.json +0 -9
  14. package/tests/automation/data/json/Pulumi.json +0 -5
  15. package/tests/automation/data/nested_config/Pulumi.dev.yaml +0 -11
  16. package/tests/automation/data/nested_config/Pulumi.yaml +0 -3
  17. package/tests/automation/data/tcfg/Pulumi.yaml +0 -4
  18. package/tests/automation/data/tcfg/index.ts +0 -1
  19. package/tests/automation/data/tcfg/package-lock.json +0 -3062
  20. package/tests/automation/data/tcfg/package.json +0 -9
  21. package/tests/automation/data/tcfg/tsconfig.json +0 -16
  22. package/tests/automation/data/testproj/Pulumi.yaml +0 -3
  23. package/tests/automation/data/testproj/go.mod +0 -71
  24. package/tests/automation/data/testproj/go.sum +0 -299
  25. package/tests/automation/data/testproj/main.go +0 -19
  26. package/tests/automation/data/testproj_dotnet/Program.cs +0 -12
  27. package/tests/automation/data/testproj_dotnet/Pulumi.yaml +0 -3
  28. package/tests/automation/data/testproj_dotnet/TestProj.csproj +0 -12
  29. package/tests/automation/data/yaml/Pulumi.dev.yaml +0 -5
  30. package/tests/automation/data/yaml/Pulumi.yaml +0 -3
  31. package/tests/automation/data/yml/Pulumi.dev.yml +0 -5
  32. package/tests/automation/data/yml/Pulumi.yml +0 -3
  33. package/tests/automation/localWorkspace.spec.d.ts +0 -1
  34. package/tests/automation/localWorkspace.spec.js +0 -1325
  35. package/tests/automation/localWorkspace.spec.js.map +0 -1
  36. package/tests/automation/remoteWorkspace.spec.d.ts +0 -1
  37. package/tests/automation/remoteWorkspace.spec.js +0 -460
  38. package/tests/automation/remoteWorkspace.spec.js.map +0 -1
  39. package/tests/automation/util.d.ts +0 -1
  40. package/tests/automation/util.js +0 -31
  41. package/tests/automation/util.js.map +0 -1
  42. package/tests/config.spec.d.ts +0 -1
  43. package/tests/config.spec.js +0 -177
  44. package/tests/config.spec.js.map +0 -1
  45. package/tests/constants.d.ts +0 -1
  46. package/tests/constants.js +0 -18
  47. package/tests/constants.js.map +0 -1
  48. package/tests/init.spec.d.ts +0 -1
  49. package/tests/init.spec.js +0 -18
  50. package/tests/init.spec.js.map +0 -1
  51. package/tests/iterable.spec.d.ts +0 -1
  52. package/tests/iterable.spec.js +0 -60
  53. package/tests/iterable.spec.js.map +0 -1
  54. package/tests/options.spec.d.ts +0 -1
  55. package/tests/options.spec.js +0 -233
  56. package/tests/options.spec.js.map +0 -1
  57. package/tests/output.spec.d.ts +0 -1
  58. package/tests/output.spec.js +0 -809
  59. package/tests/output.spec.js.map +0 -1
  60. package/tests/provider.spec.d.ts +0 -1
  61. package/tests/provider.spec.js +0 -524
  62. package/tests/provider.spec.js.map +0 -1
  63. package/tests/resource.spec.d.ts +0 -1
  64. package/tests/resource.spec.js +0 -275
  65. package/tests/resource.spec.js.map +0 -1
  66. package/tests/runtime/asyncIterableUtil.spec.d.ts +0 -1
  67. package/tests/runtime/asyncIterableUtil.spec.js +0 -115
  68. package/tests/runtime/asyncIterableUtil.spec.js.map +0 -1
  69. package/tests/runtime/closure-integration-tests.d.ts +0 -1
  70. package/tests/runtime/closure-integration-tests.js +0 -120
  71. package/tests/runtime/closure-integration-tests.js.map +0 -1
  72. package/tests/runtime/findWorkspaceRoot.spec.d.ts +0 -1
  73. package/tests/runtime/findWorkspaceRoot.spec.js +0 -62
  74. package/tests/runtime/findWorkspaceRoot.spec.js.map +0 -1
  75. package/tests/runtime/install-package-tests.d.ts +0 -1
  76. package/tests/runtime/install-package-tests.js +0 -230
  77. package/tests/runtime/install-package-tests.js.map +0 -1
  78. package/tests/runtime/langhost/cases/000.empty/index.js +0 -1
  79. package/tests/runtime/langhost/cases/001.one_resource/index.js +0 -11
  80. package/tests/runtime/langhost/cases/002.ten_resources/index.js +0 -13
  81. package/tests/runtime/langhost/cases/003.one_complex_resource/index.js +0 -77
  82. package/tests/runtime/langhost/cases/004.ten_complex_resources/index.js +0 -38
  83. package/tests/runtime/langhost/cases/004.ten_complex_resources/resource.js +0 -30
  84. package/tests/runtime/langhost/cases/005.resource_thens/index.js +0 -72
  85. package/tests/runtime/langhost/cases/006.asset/index.js +0 -13
  86. package/tests/runtime/langhost/cases/006.asset/testdata.txt +0 -4
  87. package/tests/runtime/langhost/cases/007.promises_io/index.js +0 -25
  88. package/tests/runtime/langhost/cases/007.promises_io/testdata.txt +0 -4
  89. package/tests/runtime/langhost/cases/008.ten_depends_on_resources/index.js +0 -46
  90. package/tests/runtime/langhost/cases/009.invoke/index.js +0 -25
  91. package/tests/runtime/langhost/cases/010.runtime_settings/index.js +0 -22
  92. package/tests/runtime/langhost/cases/011.unhandled_error/index.js +0 -1
  93. package/tests/runtime/langhost/cases/012.assets_archive/index.js +0 -25
  94. package/tests/runtime/langhost/cases/013.unhandled_promise_rejection/index.js +0 -3
  95. package/tests/runtime/langhost/cases/014.read_resource/index.js +0 -19
  96. package/tests/runtime/langhost/cases/015.runtime_sxs/index.js +0 -100
  97. package/tests/runtime/langhost/cases/016.promise_leak/index.js +0 -3
  98. package/tests/runtime/langhost/cases/017.parent_defaults/index.js +0 -89
  99. package/tests/runtime/langhost/cases/018.logging/index.js +0 -15
  100. package/tests/runtime/langhost/cases/019.stack_exports/index.js +0 -15
  101. package/tests/runtime/langhost/cases/020.property_dependencies/index.js +0 -39
  102. package/tests/runtime/langhost/cases/021.parent_child_dependencies/index.js +0 -15
  103. package/tests/runtime/langhost/cases/022.parent_child_dependencies_2/index.js +0 -16
  104. package/tests/runtime/langhost/cases/023.parent_child_dependencies_3/index.js +0 -28
  105. package/tests/runtime/langhost/cases/024.parent_child_dependencies_4/index.js +0 -22
  106. package/tests/runtime/langhost/cases/025.parent_child_dependencies_5/index.js +0 -24
  107. package/tests/runtime/langhost/cases/026.parent_child_dependencies_6/index.js +0 -29
  108. package/tests/runtime/langhost/cases/027.parent_child_dependencies_7/index.js +0 -36
  109. package/tests/runtime/langhost/cases/028.parent_child_dependencies_8/index.js +0 -28
  110. package/tests/runtime/langhost/cases/029.parent_child_dependencies_9/index.js +0 -23
  111. package/tests/runtime/langhost/cases/030.import_resource/index.js +0 -11
  112. package/tests/runtime/langhost/cases/040.run_error/index.js +0 -3
  113. package/tests/runtime/langhost/cases/041.component_opt_single_provider/index.js +0 -89
  114. package/tests/runtime/langhost/cases/042.component_opt_providers_array/index.js +0 -89
  115. package/tests/runtime/langhost/cases/043.depends_on_non_resource/index.js +0 -11
  116. package/tests/runtime/langhost/cases/044.versions/index.js +0 -22
  117. package/tests/runtime/langhost/cases/045.ignore_changes/index.js +0 -11
  118. package/tests/runtime/langhost/cases/046.recursive_stack_exports/index.js +0 -19
  119. package/tests/runtime/langhost/cases/047.exported_function/index.js +0 -13
  120. package/tests/runtime/langhost/cases/048.exported_promise_function/index.js +0 -13
  121. package/tests/runtime/langhost/cases/049.exported_async_function/index.js +0 -13
  122. package/tests/runtime/langhost/cases/050.resource_creation_in_function/index.js +0 -11
  123. package/tests/runtime/langhost/cases/051.resource_creation_in_function_with_result/index.js +0 -12
  124. package/tests/runtime/langhost/cases/052.resource_creation_in_async_function_with_result/index.js +0 -12
  125. package/tests/runtime/langhost/cases/060.provider_invokes/index.js +0 -26
  126. package/tests/runtime/langhost/cases/061.provider_in_parent_invokes/index.js +0 -33
  127. package/tests/runtime/langhost/cases/062.providerref_invokes/index.js +0 -33
  128. package/tests/runtime/langhost/cases/063.providerref_in_parent_invokes/index.js +0 -41
  129. package/tests/runtime/langhost/cases/064.async_components/index.js +0 -44
  130. package/tests/runtime/langhost/cases/065.large_resource/index.js +0 -17
  131. package/tests/runtime/langhost/cases/066.replace_on_changes/index.js +0 -11
  132. package/tests/runtime/langhost/cases/067.native_es_module/index.js +0 -11
  133. package/tests/runtime/langhost/cases/067.native_es_module/package.json +0 -1
  134. package/tests/runtime/langhost/cases/068.remote_component_providers/index.js +0 -34
  135. package/tests/runtime/langhost/cases/068.remote_component_providers/package.json +0 -3
  136. package/tests/runtime/langhost/cases/069.ambiguous_entrypoints/index.d.ts +0 -1
  137. package/tests/runtime/langhost/cases/069.ambiguous_entrypoints/index.js +0 -11
  138. package/tests/runtime/langhost/cases/069.ambiguous_entrypoints/index.js.map +0 -1
  139. package/tests/runtime/langhost/cases/069.ambiguous_entrypoints/index.ts +0 -23
  140. package/tests/runtime/langhost/cases/070.unusual_alias_names/index.js +0 -26
  141. package/tests/runtime/langhost/cases/071.large_alias_counts/index.js +0 -22
  142. package/tests/runtime/langhost/cases/072.large_alias_lineage_chains/index.js +0 -55
  143. package/tests/runtime/langhost/cases/073.component_dependencies/index.js +0 -28
  144. package/tests/runtime/langhost/cases/074.source_position/index.js +0 -17
  145. package/tests/runtime/langhost/run.spec.d.ts +0 -1
  146. package/tests/runtime/langhost/run.spec.js +0 -1685
  147. package/tests/runtime/langhost/run.spec.js.map +0 -1
  148. package/tests/runtime/pack.d.ts +0 -1
  149. package/tests/runtime/pack.js +0 -56
  150. package/tests/runtime/pack.js.map +0 -1
  151. package/tests/runtime/props.spec.d.ts +0 -1
  152. package/tests/runtime/props.spec.js +0 -387
  153. package/tests/runtime/props.spec.js.map +0 -1
  154. package/tests/runtime/registrations.spec.d.ts +0 -1
  155. package/tests/runtime/registrations.spec.js +0 -139
  156. package/tests/runtime/registrations.spec.js.map +0 -1
  157. package/tests/runtime/rpc.spec.d.ts +0 -1
  158. package/tests/runtime/rpc.spec.js +0 -79
  159. package/tests/runtime/rpc.spec.js.map +0 -1
  160. package/tests/runtime/settings.spec.d.ts +0 -1
  161. package/tests/runtime/settings.spec.js +0 -57
  162. package/tests/runtime/settings.spec.js.map +0 -1
  163. package/tests/runtime/testdata/nested/project/index.d.ts +0 -0
  164. package/tests/runtime/testdata/nested/project/index.js +0 -16
  165. package/tests/runtime/testdata/nested/project/index.js.map +0 -1
  166. package/tests/stackReference.spec.d.ts +0 -1
  167. package/tests/stackReference.spec.js +0 -86
  168. package/tests/stackReference.spec.js.map +0 -1
  169. package/tests/unwrap.spec.d.ts +0 -1
  170. package/tests/unwrap.spec.js +0 -254
  171. package/tests/unwrap.spec.js.map +0 -1
  172. package/tests/util.d.ts +0 -1
  173. package/tests/util.js +0 -71
  174. package/tests/util.js.map +0 -1
  175. package/tests_with_mocks/mocks.spec.d.ts +0 -1
  176. package/tests_with_mocks/mocks.spec.js +0 -182
  177. package/tests_with_mocks/mocks.spec.js.map +0 -1
@@ -1,1325 +0,0 @@
1
- "use strict";
2
- // Copyright 2016-2021, Pulumi Corporation.
3
- //
4
- // Licensed under the Apache License, Version 2.0 (the "License");
5
- // you may not use this file except in compliance with the License.
6
- // You may obtain a copy of the License at
7
- //
8
- // http://www.apache.org/licenses/LICENSE-2.0
9
- //
10
- // Unless required by applicable law or agreed to in writing, software
11
- // distributed under the License is distributed on an "AS IS" BASIS,
12
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- // See the License for the specific language governing permissions and
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
25
- return (mod && mod.__esModule) ? mod : { "default": mod };
26
- };
27
- var __importStar = (this && this.__importStar) || function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
31
- result["default"] = mod;
32
- return result;
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- const assert_1 = __importDefault(require("assert"));
36
- const semver = __importStar(require("semver"));
37
- const tmp = __importStar(require("tmp"));
38
- const upath = __importStar(require("upath"));
39
- const fs = __importStar(require("fs"));
40
- const automation_1 = require("../../automation");
41
- const index_1 = require("../../index");
42
- const util_1 = require("./util");
43
- const versionRegex = /(\d+\.)(\d+\.)(\d+)(-.*)?/;
44
- const userAgent = "pulumi/pulumi/test";
45
- describe("LocalWorkspace", () => {
46
- it(`projectSettings from yaml/yml/json`, () => __awaiter(void 0, void 0, void 0, function* () {
47
- for (const ext of ["yaml", "yml", "json"]) {
48
- const ws = yield automation_1.LocalWorkspace.create({ workDir: upath.joinSafe(__dirname, "data", ext) });
49
- const settings = yield ws.projectSettings();
50
- assert_1.default(settings.name, "testproj");
51
- assert_1.default(settings.runtime, "go");
52
- assert_1.default(settings.description, "A minimal Go Pulumi program");
53
- }
54
- }));
55
- it(`stackSettings from yaml/yml/json`, () => __awaiter(void 0, void 0, void 0, function* () {
56
- for (const ext of ["yaml", "yml", "json"]) {
57
- const ws = yield automation_1.LocalWorkspace.create({ workDir: upath.joinSafe(__dirname, "data", ext) });
58
- const settings = yield ws.stackSettings("dev");
59
- assert_1.default.strictEqual(settings.secretsProvider, "abc");
60
- assert_1.default.strictEqual(settings.config["plain"], "plain");
61
- assert_1.default.strictEqual(settings.config["secure"].secure, "secret");
62
- yield ws.saveStackSettings("dev", settings);
63
- assert_1.default.strictEqual(settings.secretsProvider, "abc");
64
- }
65
- }));
66
- it(`fails gracefully for missing local workspace workDir`, () => __awaiter(void 0, void 0, void 0, function* () {
67
- try {
68
- const ws = yield automation_1.LocalWorkspace.create({ workDir: "invalid-missing-workdir" });
69
- assert_1.default.fail("expected create with invalid workDir to throw");
70
- }
71
- catch (err) {
72
- assert_1.default.strictEqual(err.toString(), "Error: Invalid workDir passed to local workspace: 'invalid-missing-workdir' does not exist");
73
- }
74
- }));
75
- it(`adds/removes/lists plugins successfully`, () => __awaiter(void 0, void 0, void 0, function* () {
76
- const ws = yield automation_1.LocalWorkspace.create({});
77
- yield ws.installPlugin("aws", "v3.0.0");
78
- // See https://github.com/pulumi/pulumi/issues/11013 for why this is disabled
79
- //await ws.installPluginFromServer("scaleway", "v1.2.0", "github://api.github.com/lbrlabs");
80
- yield ws.removePlugin("aws", "3.0.0");
81
- yield ws.listPlugins();
82
- }));
83
- it(`create/select/remove LocalWorkspace stack`, () => __awaiter(void 0, void 0, void 0, function* () {
84
- const projectName = "node_test";
85
- const projectSettings = {
86
- name: projectName,
87
- runtime: "nodejs",
88
- };
89
- const ws = yield automation_1.LocalWorkspace.create({ projectSettings });
90
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
91
- yield ws.createStack(stackName);
92
- yield ws.selectStack(stackName);
93
- yield ws.removeStack(stackName);
94
- }));
95
- it(`create/select/createOrSelect Stack`, () => __awaiter(void 0, void 0, void 0, function* () {
96
- const projectName = "node_test";
97
- const projectSettings = {
98
- name: projectName,
99
- runtime: "nodejs",
100
- };
101
- const ws = yield automation_1.LocalWorkspace.create({ projectSettings });
102
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
103
- yield automation_1.Stack.create(stackName, ws);
104
- yield automation_1.Stack.select(stackName, ws);
105
- yield automation_1.Stack.createOrSelect(stackName, ws);
106
- yield ws.removeStack(stackName);
107
- }));
108
- describe("Tag methods: get/set/remove/list", () => {
109
- const projectName = "testProjectName";
110
- const runtime = "nodejs";
111
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
112
- const projectSettings = {
113
- name: projectName,
114
- runtime,
115
- };
116
- let workspace;
117
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
118
- workspace = yield automation_1.LocalWorkspace.create({
119
- projectSettings: projectSettings,
120
- });
121
- yield workspace.createStack(stackName);
122
- }));
123
- it("lists tag values", () => __awaiter(void 0, void 0, void 0, function* () {
124
- const result = yield workspace.listTags(stackName);
125
- assert_1.default.strictEqual(result["pulumi:project"], projectName);
126
- assert_1.default.strictEqual(result["pulumi:runtime"], runtime);
127
- }));
128
- it("sets and removes tag values", () => __awaiter(void 0, void 0, void 0, function* () {
129
- // sets
130
- yield workspace.setTag(stackName, "foo", "bar");
131
- const actualValue = yield workspace.getTag(stackName, "foo");
132
- assert_1.default.strictEqual(actualValue, "bar");
133
- // removes
134
- yield workspace.removeTag(stackName, "foo");
135
- const actualTags = yield workspace.listTags(stackName);
136
- assert_1.default.strictEqual(actualTags["foo"], undefined);
137
- }));
138
- it("gets a single tag value", () => __awaiter(void 0, void 0, void 0, function* () {
139
- const actualValue = yield workspace.getTag(stackName, "pulumi:project");
140
- assert_1.default.strictEqual(actualValue, actualValue.trim());
141
- assert_1.default.strictEqual(actualValue, projectName);
142
- }));
143
- afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
144
- yield workspace.removeStack(stackName);
145
- }));
146
- });
147
- describe("ListStack Methods", () => __awaiter(void 0, void 0, void 0, function* () {
148
- describe("ListStacks", () => __awaiter(void 0, void 0, void 0, function* () {
149
- const stackJson = `[
150
- {
151
- "name": "testorg1/testproj1/teststack1",
152
- "current": false,
153
- "url": "https://app.pulumi.com/testorg1/testproj1/teststack1"
154
- },
155
- {
156
- "name": "testorg1/testproj1/teststack2",
157
- "current": false,
158
- "url": "https://app.pulumi.com/testorg1/testproj1/teststack2"
159
- }
160
- ]`;
161
- it(`should handle stacks correctly for listStacks`, () => __awaiter(void 0, void 0, void 0, function* () {
162
- const mockWithReturnedStacks = {
163
- command: "pulumi",
164
- version: null,
165
- run: (args, cwd, additionalEnv) => __awaiter(void 0, void 0, void 0, function* () {
166
- return new automation_1.CommandResult(stackJson, "", 0);
167
- }),
168
- };
169
- const workspace = yield automation_1.LocalWorkspace.create({ pulumiCommand: mockWithReturnedStacks });
170
- const stacks = yield workspace.listStacks();
171
- assert_1.default.strictEqual(stacks.length, 2);
172
- assert_1.default.strictEqual(stacks[0].name, "testorg1/testproj1/teststack1");
173
- assert_1.default.strictEqual(stacks[0].current, false);
174
- assert_1.default.strictEqual(stacks[0].url, "https://app.pulumi.com/testorg1/testproj1/teststack1");
175
- assert_1.default.strictEqual(stacks[1].name, "testorg1/testproj1/teststack2");
176
- assert_1.default.strictEqual(stacks[1].current, false);
177
- assert_1.default.strictEqual(stacks[1].url, "https://app.pulumi.com/testorg1/testproj1/teststack2");
178
- }));
179
- it(`should use correct args for listStacks`, () => __awaiter(void 0, void 0, void 0, function* () {
180
- let capturedArgs = [];
181
- const mockPulumiCommand = {
182
- command: "pulumi",
183
- version: null,
184
- run: (args, cwd, additionalEnv) => __awaiter(void 0, void 0, void 0, function* () {
185
- capturedArgs = args;
186
- return new automation_1.CommandResult(stackJson, "", 0);
187
- }),
188
- };
189
- const workspace = yield automation_1.LocalWorkspace.create({
190
- pulumiCommand: mockPulumiCommand,
191
- });
192
- yield workspace.listStacks();
193
- assert_1.default.deepStrictEqual(capturedArgs, ["stack", "ls", "--json"]);
194
- }));
195
- }));
196
- describe("ListStacks with all", () => __awaiter(void 0, void 0, void 0, function* () {
197
- const stackJson = `[
198
- {
199
- "name": "testorg1/testproj1/teststack1",
200
- "current": false,
201
- "url": "https://app.pulumi.com/testorg1/testproj1/teststack1"
202
- },
203
- {
204
- "name": "testorg1/testproj2/teststack2",
205
- "current": false,
206
- "url": "https://app.pulumi.com/testorg1/testproj2/teststack2"
207
- }
208
- ]`;
209
- it(`should handle stacks correctly for listStacks when all is set`, () => __awaiter(void 0, void 0, void 0, function* () {
210
- const mockWithReturnedStacks = {
211
- command: "pulumi",
212
- version: null,
213
- run: () => __awaiter(void 0, void 0, void 0, function* () { return new automation_1.CommandResult(stackJson, "", 0); }),
214
- };
215
- const workspace = yield automation_1.LocalWorkspace.create({
216
- pulumiCommand: mockWithReturnedStacks,
217
- });
218
- const stacks = yield workspace.listStacks({ all: true });
219
- assert_1.default.strictEqual(stacks.length, 2);
220
- assert_1.default.strictEqual(stacks[0].name, "testorg1/testproj1/teststack1");
221
- assert_1.default.strictEqual(stacks[0].current, false);
222
- assert_1.default.strictEqual(stacks[0].url, "https://app.pulumi.com/testorg1/testproj1/teststack1");
223
- assert_1.default.strictEqual(stacks[1].name, "testorg1/testproj2/teststack2");
224
- assert_1.default.strictEqual(stacks[1].current, false);
225
- assert_1.default.strictEqual(stacks[1].url, "https://app.pulumi.com/testorg1/testproj2/teststack2");
226
- }));
227
- it(`should use correct args for listStacks when all is set`, () => __awaiter(void 0, void 0, void 0, function* () {
228
- let capturedArgs = [];
229
- const mockPuluiCommand = {
230
- command: "pulumi",
231
- version: null,
232
- run: (args, cwd, additionalEnv) => __awaiter(void 0, void 0, void 0, function* () {
233
- capturedArgs = args;
234
- return new automation_1.CommandResult(stackJson, "", 0);
235
- }),
236
- };
237
- const workspace = yield automation_1.LocalWorkspace.create({
238
- pulumiCommand: mockPuluiCommand,
239
- });
240
- yield workspace.listStacks({ all: true });
241
- assert_1.default.deepStrictEqual(capturedArgs, ["stack", "ls", "--json", "--all"]);
242
- }));
243
- }));
244
- }));
245
- it(`Environment functions`, function () {
246
- return __awaiter(this, void 0, void 0, function* () {
247
- // Skipping test because the required environments are in the moolumi org.
248
- if (util_1.getTestOrg() !== "moolumi") {
249
- this.skip();
250
- return;
251
- }
252
- const projectName = "node_env_test";
253
- const projectSettings = {
254
- name: projectName,
255
- runtime: "nodejs",
256
- };
257
- const ws = yield automation_1.LocalWorkspace.create({ projectSettings });
258
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
259
- const stack = yield automation_1.Stack.create(stackName, ws);
260
- // Adding non-existent env should fail.
261
- yield assert_1.default.rejects(stack.addEnvironments("non-existent-env"), "stack.addEnvironments('non-existent-env') did not reject");
262
- // Adding existing envs should succeed.
263
- yield stack.addEnvironments("automation-api-test-env", "automation-api-test-env-2");
264
- let envs = yield stack.listEnvironments();
265
- assert_1.default.deepStrictEqual(envs, ["automation-api-test-env", "automation-api-test-env-2"]);
266
- const config = yield stack.getAllConfig();
267
- assert_1.default.strictEqual(config["node_env_test:new_key"].value, "test_value");
268
- assert_1.default.strictEqual(config["node_env_test:also"].value, "business");
269
- // Removing existing env should succeed.
270
- yield stack.removeEnvironment("automation-api-test-env");
271
- envs = yield stack.listEnvironments();
272
- assert_1.default.deepStrictEqual(envs, ["automation-api-test-env-2"]);
273
- const alsoConfig = yield stack.getConfig("also");
274
- assert_1.default.strictEqual(alsoConfig.value, "business");
275
- yield assert_1.default.rejects(stack.getConfig("new_key"), "stack.getConfig('new_key') did not reject");
276
- yield stack.removeEnvironment("automation-api-test-env-2");
277
- envs = yield stack.listEnvironments();
278
- assert_1.default.strictEqual(envs.length, 0);
279
- yield assert_1.default.rejects(stack.getConfig("also"), "stack.getConfig('also') did not reject");
280
- yield ws.removeStack(stackName);
281
- });
282
- });
283
- it(`Config`, () => __awaiter(void 0, void 0, void 0, function* () {
284
- const projectName = "node_test";
285
- const projectSettings = {
286
- name: projectName,
287
- runtime: "nodejs",
288
- };
289
- const ws = yield automation_1.LocalWorkspace.create({ projectSettings });
290
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
291
- const stack = yield automation_1.Stack.create(stackName, ws);
292
- const config = {
293
- plain: { value: "abc" },
294
- secret: { value: "def", secret: true },
295
- };
296
- let caught = 0;
297
- const plainKey = normalizeConfigKey("plain", projectName);
298
- const secretKey = normalizeConfigKey("secret", projectName);
299
- try {
300
- yield stack.getConfig(plainKey);
301
- }
302
- catch (error) {
303
- caught++;
304
- }
305
- assert_1.default.strictEqual(caught, 1, "expected config get on empty value to throw");
306
- let values = yield stack.getAllConfig();
307
- assert_1.default.strictEqual(Object.keys(values).length, 0, "expected stack config to be empty");
308
- yield stack.setAllConfig(config);
309
- values = yield stack.getAllConfig();
310
- assert_1.default.strictEqual(values[plainKey].value, "abc");
311
- assert_1.default.strictEqual(values[plainKey].secret, false);
312
- assert_1.default.strictEqual(values[secretKey].value, "def");
313
- assert_1.default.strictEqual(values[secretKey].secret, true);
314
- yield stack.removeConfig("plain");
315
- values = yield stack.getAllConfig();
316
- assert_1.default.strictEqual(Object.keys(values).length, 1, "expected stack config to have 1 value");
317
- yield stack.setConfig("foo", { value: "bar" });
318
- values = yield stack.getAllConfig();
319
- assert_1.default.strictEqual(Object.keys(values).length, 2, "expected stack config to have 2 values");
320
- yield ws.removeStack(stackName);
321
- }));
322
- it(`config_flag_like`, () => __awaiter(void 0, void 0, void 0, function* () {
323
- const projectName = "config_flag_like";
324
- const projectSettings = {
325
- name: projectName,
326
- runtime: "nodejs",
327
- };
328
- const ws = yield automation_1.LocalWorkspace.create({ projectSettings });
329
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
330
- const stack = yield automation_1.Stack.create(stackName, ws);
331
- yield stack.setConfig("key", { value: "-value" });
332
- yield stack.setConfig("secret-key", { value: "-value", secret: true });
333
- const values = yield stack.getAllConfig();
334
- assert_1.default.strictEqual(values["config_flag_like:key"].value, "-value");
335
- assert_1.default.strictEqual(values["config_flag_like:key"].secret, false);
336
- assert_1.default.strictEqual(values["config_flag_like:secret-key"].value, "-value");
337
- assert_1.default.strictEqual(values["config_flag_like:secret-key"].secret, true);
338
- yield stack.setAllConfig({
339
- key: { value: "-value2" },
340
- "secret-key": { value: "-value2", secret: true },
341
- });
342
- const values2 = yield stack.getAllConfig();
343
- assert_1.default.strictEqual(values2["config_flag_like:key"].value, "-value2");
344
- assert_1.default.strictEqual(values2["config_flag_like:key"].secret, false);
345
- assert_1.default.strictEqual(values2["config_flag_like:secret-key"].value, "-value2");
346
- assert_1.default.strictEqual(values2["config_flag_like:secret-key"].secret, true);
347
- }));
348
- it(`Config path`, () => __awaiter(void 0, void 0, void 0, function* () {
349
- const projectName = "node_test";
350
- const projectSettings = {
351
- name: projectName,
352
- runtime: "nodejs",
353
- };
354
- const ws = yield automation_1.LocalWorkspace.create({ projectSettings });
355
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
356
- const stack = yield automation_1.Stack.create(stackName, ws);
357
- // test backward compatibility
358
- yield stack.setConfig("key1", { value: "value1" });
359
- // test new flag without subPath
360
- yield stack.setConfig("key2", { value: "value2" }, false);
361
- // test new flag with subPath
362
- yield stack.setConfig("key3.subKey1", { value: "value3" }, true);
363
- // test secret
364
- yield stack.setConfig("key4", { value: "value4", secret: true });
365
- // test subPath and key as secret
366
- yield stack.setConfig("key5.subKey1", { value: "value5", secret: true }, true);
367
- // test string with dots
368
- yield stack.setConfig("key6.subKey1", { value: "value6", secret: true });
369
- // test string with dots
370
- yield stack.setConfig("key7.subKey1", { value: "value7", secret: true }, false);
371
- // test subPath
372
- yield stack.setConfig("key7.subKey2", { value: "value8" }, true);
373
- // test subPath
374
- yield stack.setConfig("key7.subKey3", { value: "value9" }, true);
375
- // test backward compatibility
376
- const cv1 = yield stack.getConfig("key1");
377
- assert_1.default.strictEqual(cv1.value, "value1");
378
- assert_1.default.strictEqual(cv1.secret, false);
379
- // test new flag without subPath
380
- const cv2 = yield stack.getConfig("key2", false);
381
- assert_1.default.strictEqual(cv2.value, "value2");
382
- assert_1.default.strictEqual(cv2.secret, false);
383
- // test new flag with subPath
384
- const cv3 = yield stack.getConfig("key3.subKey1", true);
385
- assert_1.default.strictEqual(cv3.value, "value3");
386
- assert_1.default.strictEqual(cv3.secret, false);
387
- // test secret
388
- const cv4 = yield stack.getConfig("key4");
389
- assert_1.default.strictEqual(cv4.value, "value4");
390
- assert_1.default.strictEqual(cv4.secret, true);
391
- // test subPath and key as secret
392
- const cv5 = yield stack.getConfig("key5.subKey1", true);
393
- assert_1.default.strictEqual(cv5.value, "value5");
394
- assert_1.default.strictEqual(cv5.secret, true);
395
- // test string with dots
396
- const cv6 = yield stack.getConfig("key6.subKey1");
397
- assert_1.default.strictEqual(cv6.value, "value6");
398
- assert_1.default.strictEqual(cv6.secret, true);
399
- // test string with dots
400
- const cv7 = yield stack.getConfig("key7.subKey1", false);
401
- assert_1.default.strictEqual(cv7.value, "value7");
402
- assert_1.default.strictEqual(cv7.secret, true);
403
- // test string with dots
404
- const cv8 = yield stack.getConfig("key7.subKey2", true);
405
- assert_1.default.strictEqual(cv8.value, "value8");
406
- assert_1.default.strictEqual(cv8.secret, false);
407
- // test string with dots
408
- const cv9 = yield stack.getConfig("key7.subKey3", true);
409
- assert_1.default.strictEqual(cv9.value, "value9");
410
- assert_1.default.strictEqual(cv9.secret, false);
411
- yield stack.removeConfig("key1");
412
- yield stack.removeConfig("key2", false);
413
- yield stack.removeConfig("key3", false);
414
- yield stack.removeConfig("key4", false);
415
- yield stack.removeConfig("key5", false);
416
- yield stack.removeConfig("key6.subKey1", false);
417
- yield stack.removeConfig("key7.subKey1", false);
418
- const cfg = yield stack.getAllConfig();
419
- assert_1.default.strictEqual(cfg["node_test:key7"].value, '{"subKey2":"value8","subKey3":"value9"}');
420
- yield ws.removeStack(stackName);
421
- }));
422
- // This test requires the existence of a Pulumi.dev.yaml file because we are reading the nested
423
- // config from the file. This means we can't remove the stack at the end of the test.
424
- // We should also not include secrets in this config, because the secret encryption is only valid within
425
- // the context of a stack and org, and running this test in different orgs will fail if there are secrets.
426
- it(`nested_config`, () => __awaiter(void 0, void 0, void 0, function* () {
427
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), "nested_config", "dev");
428
- const workDir = upath.joinSafe(__dirname, "data", "nested_config");
429
- const stack = yield automation_1.LocalWorkspace.createOrSelectStack({ stackName, workDir });
430
- const allConfig = yield stack.getAllConfig();
431
- const outerVal = allConfig["nested_config:outer"];
432
- assert_1.default.strictEqual(outerVal.secret, false);
433
- assert_1.default.strictEqual(outerVal.value, '{"inner":"my_value","other":"something_else"}');
434
- const listVal = allConfig["nested_config:myList"];
435
- assert_1.default.strictEqual(listVal.secret, false);
436
- assert_1.default.strictEqual(listVal.value, '["one","two","three"]');
437
- const outer = yield stack.getConfig("outer");
438
- assert_1.default.strictEqual(outer.secret, false);
439
- assert_1.default.strictEqual(outer.value, '{"inner":"my_value","other":"something_else"}');
440
- const list = yield stack.getConfig("myList");
441
- assert_1.default.strictEqual(list.secret, false);
442
- assert_1.default.strictEqual(list.value, '["one","two","three"]');
443
- }));
444
- it(`can list stacks and currently selected stack`, () => __awaiter(void 0, void 0, void 0, function* () {
445
- const projectName = `node_list_test${util_1.getTestSuffix()}`;
446
- const projectSettings = {
447
- name: projectName,
448
- runtime: "nodejs",
449
- };
450
- const ws = yield automation_1.LocalWorkspace.create({ projectSettings });
451
- const stackNamer = () => `int_test${util_1.getTestSuffix()}`;
452
- const stackNames = [];
453
- for (let i = 0; i < 2; i++) {
454
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, stackNamer());
455
- stackNames[i] = stackName;
456
- yield automation_1.Stack.create(stackName, ws);
457
- const stackSummary = yield ws.stack();
458
- assert_1.default.strictEqual(stackSummary === null || stackSummary === void 0 ? void 0 : stackSummary.current, true);
459
- const stacks = yield ws.listStacks();
460
- assert_1.default.strictEqual(stacks.length, i + 1);
461
- }
462
- for (const name of stackNames) {
463
- yield ws.removeStack(name);
464
- }
465
- }));
466
- it(`returns valid whoami result`, () => __awaiter(void 0, void 0, void 0, function* () {
467
- const projectName = "node_test";
468
- const projectSettings = {
469
- name: projectName,
470
- runtime: "nodejs",
471
- };
472
- const ws = yield automation_1.LocalWorkspace.create({ projectSettings });
473
- const whoAmIResult = yield ws.whoAmI();
474
- assert_1.default(whoAmIResult.user !== null);
475
- assert_1.default(whoAmIResult.url !== null);
476
- }));
477
- it(`stack status methods`, () => __awaiter(void 0, void 0, void 0, function* () {
478
- const projectName = "node_test";
479
- const projectSettings = {
480
- name: projectName,
481
- runtime: "nodejs",
482
- };
483
- const ws = yield automation_1.LocalWorkspace.create({ projectSettings });
484
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
485
- const stack = yield automation_1.Stack.create(stackName, ws);
486
- const history = yield stack.history();
487
- assert_1.default.strictEqual(history.length, 0);
488
- const info = yield stack.info();
489
- assert_1.default.strictEqual(typeof info, "undefined");
490
- yield ws.removeStack(stackName);
491
- }));
492
- // TODO[pulumi/pulumi#8220] understand why this test was flaky
493
- xit(`runs through the stack lifecycle with a local program`, () => __awaiter(void 0, void 0, void 0, function* () {
494
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), "testproj", `int_test${util_1.getTestSuffix()}`);
495
- const workDir = upath.joinSafe(__dirname, "data", "testproj");
496
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, workDir });
497
- const config = {
498
- bar: { value: "abc" },
499
- buzz: { value: "secret", secret: true },
500
- };
501
- yield stack.setAllConfig(config);
502
- // pulumi up
503
- const upRes = yield stack.up({ userAgent });
504
- assert_1.default.strictEqual(Object.keys(upRes.outputs).length, 3);
505
- assert_1.default.strictEqual(upRes.outputs["exp_static"].value, "foo");
506
- assert_1.default.strictEqual(upRes.outputs["exp_static"].secret, false);
507
- assert_1.default.strictEqual(upRes.outputs["exp_cfg"].value, "abc");
508
- assert_1.default.strictEqual(upRes.outputs["exp_cfg"].secret, false);
509
- assert_1.default.strictEqual(upRes.outputs["exp_secret"].value, "secret");
510
- assert_1.default.strictEqual(upRes.outputs["exp_secret"].secret, true);
511
- assert_1.default.strictEqual(upRes.summary.kind, "update");
512
- assert_1.default.strictEqual(upRes.summary.result, "succeeded");
513
- // pulumi preview
514
- const preRes = yield stack.preview({ userAgent });
515
- assert_1.default.strictEqual(preRes.changeSummary.same, 1);
516
- // pulumi refresh
517
- const refRes = yield stack.refresh({ userAgent });
518
- assert_1.default.strictEqual(refRes.summary.kind, "refresh");
519
- assert_1.default.strictEqual(refRes.summary.result, "succeeded");
520
- // pulumi destroy
521
- const destroyRes = yield stack.destroy({ userAgent });
522
- assert_1.default.strictEqual(destroyRes.summary.kind, "destroy");
523
- assert_1.default.strictEqual(destroyRes.summary.result, "succeeded");
524
- yield stack.workspace.removeStack(stackName);
525
- }));
526
- it(`runs through the stack lifecycle with a local dotnet program`, () => __awaiter(void 0, void 0, void 0, function* () {
527
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), "testproj_dotnet", `int_test${util_1.getTestSuffix()}`);
528
- const workDir = upath.joinSafe(__dirname, "data", "testproj_dotnet");
529
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, workDir });
530
- // pulumi up
531
- const upRes = yield stack.up({ userAgent });
532
- assert_1.default.strictEqual(Object.keys(upRes.outputs).length, 1);
533
- assert_1.default.strictEqual(upRes.outputs["exp_static"].value, "foo");
534
- assert_1.default.strictEqual(upRes.outputs["exp_static"].secret, false);
535
- assert_1.default.strictEqual(upRes.summary.kind, "update");
536
- assert_1.default.strictEqual(upRes.summary.result, "succeeded");
537
- // pulumi preview
538
- const preRes = yield stack.preview({ userAgent });
539
- assert_1.default.strictEqual(preRes.changeSummary.same, 1);
540
- // pulumi refresh
541
- const refRes = yield stack.refresh({ userAgent });
542
- assert_1.default.strictEqual(refRes.summary.kind, "refresh");
543
- assert_1.default.strictEqual(refRes.summary.result, "succeeded");
544
- // pulumi destroy
545
- const destroyRes = yield stack.destroy({ userAgent });
546
- assert_1.default.strictEqual(destroyRes.summary.kind, "destroy");
547
- assert_1.default.strictEqual(destroyRes.summary.result, "succeeded");
548
- yield stack.workspace.removeStack(stackName);
549
- }));
550
- it(`runs through the stack lifecycle with an inline program`, () => __awaiter(void 0, void 0, void 0, function* () {
551
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
552
- const config = new index_1.Config();
553
- return {
554
- exp_static: "foo",
555
- exp_cfg: config.get("bar"),
556
- exp_secret: config.getSecret("buzz"),
557
- };
558
- });
559
- const projectName = "inline_node";
560
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
561
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
562
- const stackConfig = {
563
- bar: { value: "abc" },
564
- buzz: { value: "secret", secret: true },
565
- };
566
- yield stack.setAllConfig(stackConfig);
567
- // pulumi up
568
- const upRes = yield stack.up({ userAgent });
569
- assert_1.default.strictEqual(Object.keys(upRes.outputs).length, 3);
570
- assert_1.default.strictEqual(upRes.outputs["exp_static"].value, "foo");
571
- assert_1.default.strictEqual(upRes.outputs["exp_static"].secret, false);
572
- assert_1.default.strictEqual(upRes.outputs["exp_cfg"].value, "abc");
573
- assert_1.default.strictEqual(upRes.outputs["exp_cfg"].secret, false);
574
- assert_1.default.strictEqual(upRes.outputs["exp_secret"].value, "secret");
575
- assert_1.default.strictEqual(upRes.outputs["exp_secret"].secret, true);
576
- assert_1.default.strictEqual(upRes.summary.kind, "update");
577
- assert_1.default.strictEqual(upRes.summary.result, "succeeded");
578
- // pulumi preview
579
- const preRes = yield stack.preview({ userAgent });
580
- assert_1.default.strictEqual(preRes.changeSummary.same, 1);
581
- // pulumi refresh
582
- const refRes = yield stack.refresh({ userAgent });
583
- assert_1.default.strictEqual(refRes.summary.kind, "refresh");
584
- assert_1.default.strictEqual(refRes.summary.result, "succeeded");
585
- // pulumi destroy
586
- const destroyRes = yield stack.destroy({ userAgent });
587
- assert_1.default.strictEqual(destroyRes.summary.kind, "destroy");
588
- assert_1.default.strictEqual(destroyRes.summary.result, "succeeded");
589
- yield stack.workspace.removeStack(stackName);
590
- }));
591
- it(`runs through the stack lifecycle with an inline program, testing removing without destroying`, () => __awaiter(void 0, void 0, void 0, function* () {
592
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
593
- class MyResource extends index_1.ComponentResource {
594
- constructor(name, opts) {
595
- super("my:module:MyResource", name, {}, opts);
596
- }
597
- }
598
- new MyResource("res");
599
- return {};
600
- });
601
- const projectName = "inline_node";
602
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
603
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
604
- yield stack.up({ userAgent });
605
- // we shouldn't be able to remove the stack without force
606
- // since the stack has an active resource
607
- assert_1.default.rejects(stack.workspace.removeStack(stackName));
608
- yield stack.workspace.removeStack(stackName, { force: true });
609
- // we shouldn't be able to select the stack after it's been removed
610
- // we expect this error
611
- assert_1.default.rejects(stack.workspace.selectStack(stackName));
612
- }));
613
- it("runs through the stack lifecycle with an inline program, testing destroy with --remove", () => __awaiter(void 0, void 0, void 0, function* () {
614
- // Arrange.
615
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
616
- class MyResource extends index_1.ComponentResource {
617
- constructor(name, opts) {
618
- super("my:module:MyResource", name, {}, opts);
619
- }
620
- }
621
- new MyResource("res");
622
- return {};
623
- });
624
- const projectName = "inline_node";
625
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
626
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
627
- yield stack.up({ userAgent });
628
- // Act.
629
- yield stack.destroy({ userAgent, remove: true });
630
- // Assert.
631
- yield assert_1.default.rejects(stack.workspace.selectStack(stackName));
632
- }));
633
- it(`refreshes with refresh option`, () => __awaiter(void 0, void 0, void 0, function* () {
634
- // We create a simple program, and scan the output for an indication
635
- // that adding refresh: true will perfrom a refresh operation.
636
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
637
- return {
638
- toggle: true,
639
- };
640
- });
641
- const projectName = "inline_node";
642
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
643
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
644
- // • First, run Up so we can set the initial state.
645
- yield stack.up({ userAgent });
646
- // • Next, run preview with refresh and check that the refresh was performed.
647
- const refresh = true;
648
- const previewRes = yield stack.preview({ userAgent, refresh });
649
- assert_1.default.match(previewRes.stdout, /refreshing/);
650
- assert_1.default.strictEqual(previewRes.changeSummary.same, 1, "preview expected 1 same (the stack)");
651
- const upRes = yield stack.up({ userAgent, refresh });
652
- assert_1.default.match(upRes.stdout, /refreshing/);
653
- const destroyRes = yield stack.destroy({ userAgent, refresh });
654
- assert_1.default.match(destroyRes.stdout, /refreshing/);
655
- }));
656
- it(`destroys an inline program with excludeProtected`, () => __awaiter(void 0, void 0, void 0, function* () {
657
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
658
- var _a;
659
- class MyResource extends index_1.ComponentResource {
660
- constructor(name, opts) {
661
- super("my:module:MyResource", name, {}, opts);
662
- }
663
- }
664
- const config = new index_1.Config();
665
- const protect = (_a = config.getBoolean("protect")) !== null && _a !== void 0 ? _a : false;
666
- new MyResource("first", { protect });
667
- new MyResource("second");
668
- return {};
669
- });
670
- const projectName = "inline_node";
671
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
672
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
673
- // initial up
674
- yield stack.setConfig("protect", { value: "true" });
675
- yield stack.up({ userAgent });
676
- // pulumi destroy
677
- const destroyRes = yield stack.destroy({ userAgent, excludeProtected: true });
678
- assert_1.default.strictEqual(destroyRes.summary.kind, "destroy");
679
- assert_1.default.strictEqual(destroyRes.summary.result, "succeeded");
680
- assert_1.default.match(destroyRes.stdout, /All unprotected resources were destroyed/);
681
- // unprotected resources
682
- yield stack.removeConfig("protect");
683
- yield stack.up({ userAgent });
684
- // pulumi destroy to cleanup all resources
685
- yield stack.destroy({ userAgent });
686
- yield stack.workspace.removeStack(stackName);
687
- }));
688
- it(`successfully initializes multiple stacks`, () => __awaiter(void 0, void 0, void 0, function* () {
689
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
690
- const config = new index_1.Config();
691
- return {
692
- exp_static: "foo",
693
- exp_cfg: config.get("bar"),
694
- exp_secret: config.getSecret("buzz"),
695
- };
696
- });
697
- const projectName = "inline_node";
698
- const stackNames = Array.from(Array(10).keys()).map((_) => automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`));
699
- const stacks = yield Promise.all(stackNames.map((stackName) => __awaiter(void 0, void 0, void 0, function* () { return automation_1.LocalWorkspace.createStack({ stackName, projectName, program }); })));
700
- yield stacks.map((stack) => stack.workspace.removeStack(stack.name));
701
- }));
702
- it(`runs through the stack lifecycle with multiple inline programs in parallel`, () => __awaiter(void 0, void 0, void 0, function* () {
703
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
704
- const config = new index_1.Config();
705
- return {
706
- exp_static: "foo",
707
- exp_cfg: config.get("bar"),
708
- exp_secret: config.getSecret("buzz"),
709
- };
710
- });
711
- const projectName = "inline_node";
712
- const stackNames = Array.from(Array(30).keys()).map((_) => automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`));
713
- const testStackLifetime = (stackName) => __awaiter(void 0, void 0, void 0, function* () {
714
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
715
- const stackConfig = {
716
- bar: { value: "abc" },
717
- buzz: { value: "secret", secret: true },
718
- };
719
- yield stack.setAllConfig(stackConfig);
720
- // pulumi up
721
- const upRes = yield stack.up({ userAgent }); // pulumi up
722
- assert_1.default.strictEqual(Object.keys(upRes.outputs).length, 3);
723
- assert_1.default.strictEqual(upRes.outputs["exp_static"].value, "foo");
724
- assert_1.default.strictEqual(upRes.outputs["exp_static"].secret, false);
725
- assert_1.default.strictEqual(upRes.outputs["exp_cfg"].value, "abc");
726
- assert_1.default.strictEqual(upRes.outputs["exp_cfg"].secret, false);
727
- assert_1.default.strictEqual(upRes.outputs["exp_secret"].value, "secret");
728
- assert_1.default.strictEqual(upRes.outputs["exp_secret"].secret, true);
729
- assert_1.default.strictEqual(upRes.summary.kind, "update");
730
- assert_1.default.strictEqual(upRes.summary.result, "succeeded");
731
- // pulumi preview
732
- const preRes = yield stack.preview({ userAgent }); // pulumi preview
733
- assert_1.default.strictEqual(preRes.changeSummary.same, 1);
734
- // pulumi refresh
735
- const refRes = yield stack.refresh({ userAgent });
736
- assert_1.default.strictEqual(refRes.summary.kind, "refresh");
737
- assert_1.default.strictEqual(refRes.summary.result, "succeeded");
738
- // pulumi destroy
739
- const destroyRes = yield stack.destroy({ userAgent });
740
- assert_1.default.strictEqual(destroyRes.summary.kind, "destroy");
741
- assert_1.default.strictEqual(destroyRes.summary.result, "succeeded");
742
- yield stack.workspace.removeStack(stack.name);
743
- });
744
- for (let i = 0; i < stackNames.length; i += 10) {
745
- const chunk = stackNames.slice(i, i + 10);
746
- yield Promise.all(chunk.map((stackName) => __awaiter(void 0, void 0, void 0, function* () { return yield testStackLifetime(stackName); })));
747
- }
748
- }));
749
- it(`handles events`, () => __awaiter(void 0, void 0, void 0, function* () {
750
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
751
- const config = new index_1.Config();
752
- return {
753
- exp_static: "foo",
754
- exp_cfg: config.get("bar"),
755
- exp_secret: config.getSecret("buzz"),
756
- };
757
- });
758
- const projectName = "inline_node";
759
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
760
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
761
- const stackConfig = {
762
- bar: { value: "abc" },
763
- buzz: { value: "secret", secret: true },
764
- };
765
- yield stack.setAllConfig(stackConfig);
766
- let seenSummaryEvent = false;
767
- const findSummaryEvent = (event) => {
768
- if (event.summaryEvent) {
769
- seenSummaryEvent = true;
770
- }
771
- };
772
- // pulumi preview
773
- const preRes = yield stack.preview({ onEvent: findSummaryEvent });
774
- assert_1.default.strictEqual(seenSummaryEvent, true, "No SummaryEvent for `preview`");
775
- assert_1.default.strictEqual(preRes.changeSummary.create, 1);
776
- // pulumi up
777
- seenSummaryEvent = false;
778
- const upRes = yield stack.up({ onEvent: findSummaryEvent });
779
- assert_1.default.strictEqual(seenSummaryEvent, true, "No SummaryEvent for `up`");
780
- assert_1.default.strictEqual(upRes.summary.kind, "update");
781
- assert_1.default.strictEqual(upRes.summary.result, "succeeded");
782
- // pulumi preview
783
- seenSummaryEvent = false;
784
- const preResAgain = yield stack.preview({ onEvent: findSummaryEvent });
785
- assert_1.default.strictEqual(seenSummaryEvent, true, "No SummaryEvent for `preview`");
786
- assert_1.default.strictEqual(preResAgain.changeSummary.same, 1);
787
- // pulumi refresh
788
- seenSummaryEvent = false;
789
- const refRes = yield stack.refresh({ onEvent: findSummaryEvent });
790
- assert_1.default.strictEqual(seenSummaryEvent, true, "No SummaryEvent for `refresh`");
791
- assert_1.default.strictEqual(refRes.summary.kind, "refresh");
792
- assert_1.default.strictEqual(refRes.summary.result, "succeeded");
793
- // pulumi destroy
794
- seenSummaryEvent = false;
795
- const destroyRes = yield stack.destroy({ onEvent: findSummaryEvent });
796
- assert_1.default.strictEqual(seenSummaryEvent, true, "No SummaryEvent for `destroy`");
797
- assert_1.default.strictEqual(destroyRes.summary.kind, "destroy");
798
- assert_1.default.strictEqual(destroyRes.summary.result, "succeeded");
799
- yield stack.workspace.removeStack(stackName);
800
- }));
801
- // TODO[pulumi/pulumi#7127]: Re-enabled the warning.
802
- // Temporarily skipping test until we've re-enabled the warning.
803
- it.skip(`has secret config warnings`, () => __awaiter(void 0, void 0, void 0, function* () {
804
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
805
- const config = new index_1.Config();
806
- config.get("plainstr1");
807
- config.require("plainstr2");
808
- config.getSecret("plainstr3");
809
- config.requireSecret("plainstr4");
810
- config.getBoolean("plainbool1");
811
- config.requireBoolean("plainbool2");
812
- config.getSecretBoolean("plainbool3");
813
- config.requireSecretBoolean("plainbool4");
814
- config.getNumber("plainnum1");
815
- config.requireNumber("plainnum2");
816
- config.getSecretNumber("plainnum3");
817
- config.requireSecretNumber("plainnum4");
818
- config.getObject("plainobj1");
819
- config.requireObject("plainobj2");
820
- config.getSecretObject("plainobj3");
821
- config.requireSecretObject("plainobj4");
822
- config.get("str1");
823
- config.require("str2");
824
- config.getSecret("str3");
825
- config.requireSecret("str4");
826
- config.getBoolean("bool1");
827
- config.requireBoolean("bool2");
828
- config.getSecretBoolean("bool3");
829
- config.requireSecretBoolean("bool4");
830
- config.getNumber("num1");
831
- config.requireNumber("num2");
832
- config.getSecretNumber("num3");
833
- config.requireSecretNumber("num4");
834
- config.getObject("obj1");
835
- config.requireObject("obj2");
836
- config.getSecretObject("obj3");
837
- config.requireSecretObject("obj4");
838
- });
839
- const projectName = "inline_node";
840
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
841
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
842
- const stackConfig = {
843
- plainstr1: { value: "1" },
844
- plainstr2: { value: "2" },
845
- plainstr3: { value: "3" },
846
- plainstr4: { value: "4" },
847
- plainbool1: { value: "true" },
848
- plainbool2: { value: "true" },
849
- plainbool3: { value: "true" },
850
- plainbool4: { value: "true" },
851
- plainnum1: { value: "1" },
852
- plainnum2: { value: "2" },
853
- plainnum3: { value: "3" },
854
- plainnum4: { value: "4" },
855
- plainobj1: { value: "{}" },
856
- plainobj2: { value: "{}" },
857
- plainobj3: { value: "{}" },
858
- plainobj4: { value: "{}" },
859
- str1: { value: "1", secret: true },
860
- str2: { value: "2", secret: true },
861
- str3: { value: "3", secret: true },
862
- str4: { value: "4", secret: true },
863
- bool1: { value: "true", secret: true },
864
- bool2: { value: "true", secret: true },
865
- bool3: { value: "true", secret: true },
866
- bool4: { value: "true", secret: true },
867
- num1: { value: "1", secret: true },
868
- num2: { value: "2", secret: true },
869
- num3: { value: "3", secret: true },
870
- num4: { value: "4", secret: true },
871
- obj1: { value: "{}", secret: true },
872
- obj2: { value: "{}", secret: true },
873
- obj3: { value: "{}", secret: true },
874
- obj4: { value: "{}", secret: true },
875
- };
876
- yield stack.setAllConfig(stackConfig);
877
- let events = [];
878
- const findDiagnosticEvents = (event) => {
879
- var _a;
880
- if (((_a = event.diagnosticEvent) === null || _a === void 0 ? void 0 : _a.severity) === "warning") {
881
- events.push(event.diagnosticEvent.message);
882
- }
883
- };
884
- const expectedWarnings = [
885
- "Configuration 'inline_node:str1' value is a secret; use `getSecret` instead of `get`",
886
- "Configuration 'inline_node:str2' value is a secret; use `requireSecret` instead of `require`",
887
- "Configuration 'inline_node:bool1' value is a secret; use `getSecretBoolean` instead of `getBoolean`",
888
- "Configuration 'inline_node:bool2' value is a secret; use `requireSecretBoolean` instead of `requireBoolean`",
889
- "Configuration 'inline_node:num1' value is a secret; use `getSecretNumber` instead of `getNumber`",
890
- "Configuration 'inline_node:num2' value is a secret; use `requireSecretNumber` instead of `requireNumber`",
891
- "Configuration 'inline_node:obj1' value is a secret; use `getSecretObject` instead of `getObject`",
892
- "Configuration 'inline_node:obj2' value is a secret; use `requireSecretObject` instead of `requireObject`",
893
- ];
894
- // These keys should not be in any warning messages.
895
- const unexpectedWarnings = [
896
- "plainstr1",
897
- "plainstr2",
898
- "plainstr3",
899
- "plainstr4",
900
- "plainbool1",
901
- "plainbool2",
902
- "plainbool3",
903
- "plainbool4",
904
- "plainnum1",
905
- "plainnum2",
906
- "plainnum3",
907
- "plainnum4",
908
- "plainobj1",
909
- "plainobj2",
910
- "plainobj3",
911
- "plainobj4",
912
- "str3",
913
- "str4",
914
- "bool3",
915
- "bool4",
916
- "num3",
917
- "num4",
918
- "obj3",
919
- "obj4",
920
- ];
921
- const validate = (warnings) => {
922
- for (const expected of expectedWarnings) {
923
- let found = false;
924
- for (const warning of warnings) {
925
- if (warning.includes(expected)) {
926
- found = true;
927
- break;
928
- }
929
- }
930
- assert_1.default.strictEqual(found, true, `expected warning not found`);
931
- }
932
- for (const unexpected of unexpectedWarnings) {
933
- for (const warning of warnings) {
934
- assert_1.default.strictEqual(warning.includes(unexpected), false, `Unexpected '${unexpected}' found in warning`);
935
- }
936
- }
937
- };
938
- // pulumi preview
939
- yield stack.preview({ onEvent: findDiagnosticEvents });
940
- validate(events);
941
- // pulumi up
942
- events = [];
943
- yield stack.up({ onEvent: findDiagnosticEvents });
944
- validate(events);
945
- yield stack.workspace.removeStack(stackName);
946
- }));
947
- it(`imports and exports stacks`, () => __awaiter(void 0, void 0, void 0, function* () {
948
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
949
- const config = new index_1.Config();
950
- return {
951
- exp_static: "foo",
952
- exp_cfg: config.get("bar"),
953
- exp_secret: config.getSecret("buzz"),
954
- };
955
- });
956
- const projectName = "import_export_node";
957
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
958
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
959
- try {
960
- yield stack.setAllConfig({
961
- bar: { value: "abc" },
962
- buzz: { value: "secret", secret: true },
963
- });
964
- yield stack.up();
965
- // export stack
966
- const state = yield stack.exportStack();
967
- // import stack
968
- yield stack.importStack(state);
969
- const configVal = yield stack.getConfig("bar");
970
- assert_1.default.strictEqual(configVal.value, "abc");
971
- }
972
- finally {
973
- const destroyRes = yield stack.destroy();
974
- assert_1.default.strictEqual(destroyRes.summary.kind, "destroy");
975
- assert_1.default.strictEqual(destroyRes.summary.result, "succeeded");
976
- yield stack.workspace.removeStack(stackName);
977
- }
978
- }));
979
- // TODO[pulumi/pulumi#8061] flaky test
980
- xit(`supports stack outputs`, () => __awaiter(void 0, void 0, void 0, function* () {
981
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
982
- const config = new index_1.Config();
983
- return {
984
- exp_static: "foo",
985
- exp_cfg: config.get("bar"),
986
- exp_secret: config.getSecret("buzz"),
987
- };
988
- });
989
- const projectName = "import_export_node";
990
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
991
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
992
- const assertOutputs = (outputs) => {
993
- assert_1.default.strictEqual(Object.keys(outputs).length, 3, "expected to have 3 outputs");
994
- assert_1.default.strictEqual(outputs["exp_static"].value, "foo");
995
- assert_1.default.strictEqual(outputs["exp_static"].secret, false);
996
- assert_1.default.strictEqual(outputs["exp_cfg"].value, "abc");
997
- assert_1.default.strictEqual(outputs["exp_cfg"].secret, false);
998
- assert_1.default.strictEqual(outputs["exp_secret"].value, "secret");
999
- assert_1.default.strictEqual(outputs["exp_secret"].secret, true);
1000
- };
1001
- try {
1002
- yield stack.setAllConfig({
1003
- bar: { value: "abc" },
1004
- buzz: { value: "secret", secret: true },
1005
- });
1006
- const initialOutputs = yield stack.outputs();
1007
- assert_1.default.strictEqual(Object.keys(initialOutputs).length, 0, "expected initialOutputs to be empty");
1008
- // pulumi up
1009
- const upRes = yield stack.up();
1010
- assert_1.default.strictEqual(upRes.summary.kind, "update");
1011
- assert_1.default.strictEqual(upRes.summary.result, "succeeded");
1012
- assertOutputs(upRes.outputs);
1013
- const outputsAfterUp = yield stack.outputs();
1014
- assertOutputs(outputsAfterUp);
1015
- const destroyRes = yield stack.destroy();
1016
- assert_1.default.strictEqual(destroyRes.summary.kind, "destroy");
1017
- assert_1.default.strictEqual(destroyRes.summary.result, "succeeded");
1018
- const outputsAfterDestroy = yield stack.outputs();
1019
- assert_1.default.strictEqual(Object.keys(outputsAfterDestroy).length, 0, "expected outputsAfterDestroy to be empty");
1020
- }
1021
- finally {
1022
- yield stack.workspace.removeStack(stackName);
1023
- }
1024
- }));
1025
- it(`runs an inline program that exits gracefully`, () => __awaiter(void 0, void 0, void 0, function* () {
1026
- const program = () => __awaiter(void 0, void 0, void 0, function* () { return ({}); });
1027
- const projectName = "inline_node";
1028
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
1029
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
1030
- // pulumi up
1031
- yield assert_1.default.doesNotReject(stack.up());
1032
- // pulumi destroy
1033
- const destroyRes = yield stack.destroy();
1034
- assert_1.default.strictEqual(destroyRes.summary.kind, "destroy");
1035
- assert_1.default.strictEqual(destroyRes.summary.result, "succeeded");
1036
- yield stack.workspace.removeStack(stackName);
1037
- }));
1038
- it(`runs an inline program that rejects a promise and exits gracefully`, () => __awaiter(void 0, void 0, void 0, function* () {
1039
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
1040
- Promise.reject(new Error());
1041
- return {};
1042
- });
1043
- const projectName = "inline_node";
1044
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
1045
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
1046
- // pulumi up
1047
- yield assert_1.default.rejects(stack.up());
1048
- // pulumi destroy
1049
- const destroyRes = yield stack.destroy();
1050
- assert_1.default.strictEqual(destroyRes.summary.kind, "destroy");
1051
- assert_1.default.strictEqual(destroyRes.summary.result, "succeeded");
1052
- yield stack.workspace.removeStack(stackName);
1053
- }));
1054
- it(`runs successfully after a previous failure`, () => __awaiter(void 0, void 0, void 0, function* () {
1055
- let shouldFail = true;
1056
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
1057
- if (shouldFail) {
1058
- Promise.reject(new Error());
1059
- }
1060
- return {};
1061
- });
1062
- const projectName = "inline_node";
1063
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
1064
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
1065
- // pulumi up rejects the first time
1066
- yield assert_1.default.rejects(stack.up());
1067
- // pulumi up succeeds the 2nd time
1068
- shouldFail = false;
1069
- yield assert_1.default.doesNotReject(stack.up());
1070
- // pulumi destroy
1071
- const destroyRes = yield stack.destroy();
1072
- assert_1.default.strictEqual(destroyRes.summary.kind, "destroy");
1073
- assert_1.default.strictEqual(destroyRes.summary.result, "succeeded");
1074
- yield stack.workspace.removeStack(stackName);
1075
- }));
1076
- it("can import resources into a stack using resource definitions", () => __awaiter(void 0, void 0, void 0, function* () {
1077
- const workDir = upath.joinSafe(__dirname, "data", "import");
1078
- const stackName = `int_test${util_1.getTestSuffix()}`;
1079
- const stack = yield automation_1.LocalWorkspace.createStack({ workDir, stackName });
1080
- const pulumiRandomVersion = "4.16.3";
1081
- yield stack.workspace.installPlugin("random", pulumiRandomVersion);
1082
- const result = yield stack.import({
1083
- protect: false,
1084
- resources: [
1085
- {
1086
- type: "random:index/randomPassword:RandomPassword",
1087
- name: "randomPassword",
1088
- id: "supersecret",
1089
- },
1090
- ],
1091
- });
1092
- assert_1.default.strictEqual(result.summary.kind, "update");
1093
- assert_1.default.strictEqual(result.summary.result, "succeeded");
1094
- const expectedGeneratedCode = fs.readFileSync(upath.joinSafe(workDir, "expected_generated_code.txt"), "utf8");
1095
- assert_1.default.strictEqual(result.generatedCode, expectedGeneratedCode);
1096
- yield stack.destroy();
1097
- yield stack.workspace.removeStack(stackName);
1098
- yield stack.workspace.removePlugin("random", pulumiRandomVersion);
1099
- }));
1100
- it("can import resources into a stack without generating code", () => __awaiter(void 0, void 0, void 0, function* () {
1101
- const workDir = upath.joinSafe(__dirname, "data", "import");
1102
- const stackName = `int_test${util_1.getTestSuffix()}`;
1103
- const stack = yield automation_1.LocalWorkspace.createStack({ workDir, stackName });
1104
- const pulumiRandomVersion = "4.16.3";
1105
- yield stack.workspace.installPlugin("random", pulumiRandomVersion);
1106
- const result = yield stack.import({
1107
- protect: false,
1108
- generateCode: false,
1109
- resources: [
1110
- {
1111
- type: "random:index/randomPassword:RandomPassword",
1112
- name: "randomPassword",
1113
- id: "supersecret",
1114
- },
1115
- ],
1116
- });
1117
- assert_1.default.strictEqual(result.summary.kind, "update");
1118
- assert_1.default.strictEqual(result.summary.result, "succeeded");
1119
- assert_1.default.strictEqual(result.generatedCode, "");
1120
- yield stack.destroy();
1121
- yield stack.workspace.removeStack(stackName);
1122
- yield stack.workspace.removePlugin("random", pulumiRandomVersion);
1123
- }));
1124
- it(`sets pulumi version`, () => __awaiter(void 0, void 0, void 0, function* () {
1125
- const ws = yield automation_1.LocalWorkspace.create({});
1126
- assert_1.default(ws.pulumiVersion);
1127
- assert_1.default.strictEqual(versionRegex.test(ws.pulumiVersion), true);
1128
- }));
1129
- it("sets pulumi version when using a custom CLI instance", () => __awaiter(void 0, void 0, void 0, function* () {
1130
- const tmpDir = tmp.dirSync({ prefix: "automation-test-", unsafeCleanup: true });
1131
- try {
1132
- const cmd = yield automation_1.PulumiCommand.get();
1133
- const ws = yield automation_1.LocalWorkspace.create({ pulumiCommand: cmd });
1134
- assert_1.default.strictEqual(versionRegex.test(ws.pulumiVersion), true);
1135
- }
1136
- finally {
1137
- tmpDir.removeCallback();
1138
- }
1139
- }));
1140
- it("throws when attempting to retrieve an invalid pulumi version", () => __awaiter(void 0, void 0, void 0, function* () {
1141
- const mockWithNoVersion = {
1142
- command: "pulumi",
1143
- version: null,
1144
- run: () => __awaiter(void 0, void 0, void 0, function* () { return new automation_1.CommandResult("some output", "", 0); }),
1145
- };
1146
- const ws = yield automation_1.LocalWorkspace.create({
1147
- pulumiCommand: mockWithNoVersion,
1148
- envVars: {
1149
- PULUMI_AUTOMATION_API_SKIP_VERSION_CHECK: "true",
1150
- },
1151
- });
1152
- assert_1.default.throws(() => ws.pulumiVersion);
1153
- }));
1154
- it("fails creation if remote operation is not supported", () => __awaiter(void 0, void 0, void 0, function* () {
1155
- const mockWithNoRemoteSupport = {
1156
- command: "pulumi",
1157
- version: new semver.SemVer("2.0.0"),
1158
- // We inspect the output of `pulumi preview --help` to determine
1159
- // if the CLI supports remote operations, see
1160
- // `LocalWorkspace.checkRemoteSupport`.
1161
- run: () => __awaiter(void 0, void 0, void 0, function* () { return new automation_1.CommandResult("some output", "", 0); }),
1162
- };
1163
- yield assert_1.default.rejects(automation_1.LocalWorkspace.create({ pulumiCommand: mockWithNoRemoteSupport, remote: true }));
1164
- }));
1165
- it("bypasses remote support check", () => __awaiter(void 0, void 0, void 0, function* () {
1166
- const mockWithNoRemoteSupport = {
1167
- command: "pulumi",
1168
- version: new semver.SemVer("2.0.0"),
1169
- // We inspect the output of `pulumi preview --help` to determine
1170
- // if the CLI supports remote operations, see
1171
- // `LocalWorkspace.checkRemoteSupport`.
1172
- run: () => __awaiter(void 0, void 0, void 0, function* () { return new automation_1.CommandResult("some output", "", 0); }),
1173
- };
1174
- yield assert_1.default.doesNotReject(automation_1.LocalWorkspace.create({
1175
- pulumiCommand: mockWithNoRemoteSupport,
1176
- remote: true,
1177
- envVars: {
1178
- PULUMI_AUTOMATION_API_SKIP_VERSION_CHECK: "true",
1179
- },
1180
- }));
1181
- }));
1182
- it(`respects existing project settings`, () => __awaiter(void 0, void 0, void 0, function* () {
1183
- const projectName = "correct_project";
1184
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
1185
- const stack = yield automation_1.LocalWorkspace.createStack({
1186
- stackName,
1187
- projectName,
1188
- program: () => __awaiter(void 0, void 0, void 0, function* () {
1189
- return;
1190
- }),
1191
- }, { workDir: upath.joinSafe(__dirname, "data", "correct_project") });
1192
- const projectSettings = yield stack.workspace.projectSettings();
1193
- assert_1.default.strictEqual(projectSettings.name, "correct_project");
1194
- // the description check is enough to verify that the stack wasn't overwritten
1195
- assert_1.default.strictEqual(projectSettings.description, "This is a description");
1196
- yield stack.workspace.removeStack(stackName);
1197
- }));
1198
- it(`correctly sets config on multiple stacks concurrently`, () => __awaiter(void 0, void 0, void 0, function* () {
1199
- const dones = [];
1200
- const stacks = ["dev", "dev2", "dev3", "dev4", "dev5"];
1201
- const workDir = upath.joinSafe(__dirname, "data", "tcfg");
1202
- const ws = yield automation_1.LocalWorkspace.create({
1203
- workDir,
1204
- projectSettings: {
1205
- name: "concurrent-config",
1206
- runtime: "nodejs",
1207
- backend: { url: "file://~" },
1208
- },
1209
- envVars: {
1210
- PULUMI_CONFIG_PASSPHRASE: "test",
1211
- },
1212
- });
1213
- for (let i = 0; i < stacks.length; i++) {
1214
- yield automation_1.Stack.create(stacks[i], ws);
1215
- }
1216
- for (let i = 0; i < stacks.length; i++) {
1217
- const x = i;
1218
- const s = stacks[i];
1219
- dones.push((() => __awaiter(void 0, void 0, void 0, function* () {
1220
- for (let j = 0; j < 20; j++) {
1221
- yield ws.setConfig(s, "var-" + j, { value: (x * 20 + j).toString() });
1222
- }
1223
- }))());
1224
- }
1225
- yield Promise.all(dones);
1226
- for (let i = 0; i < stacks.length; i++) {
1227
- const stack = yield automation_1.LocalWorkspace.selectStack({
1228
- stackName: stacks[i],
1229
- workDir,
1230
- });
1231
- const config = yield stack.getAllConfig();
1232
- assert_1.default.strictEqual(Object.keys(config).length, 20);
1233
- yield stack.workspace.removeStack(stacks[i]);
1234
- }
1235
- }));
1236
- it(`runs the install command`, () => __awaiter(void 0, void 0, void 0, function* () {
1237
- let recordedArgs = [];
1238
- const mockCommand = {
1239
- command: "pulumi",
1240
- // Version high enough to support --use-language-version-tools
1241
- version: semver.parse("3.130.0"),
1242
- run: (args, cwd, additionalEnv, onOutput) => __awaiter(void 0, void 0, void 0, function* () {
1243
- recordedArgs = args;
1244
- return new automation_1.CommandResult("some output", "", 0);
1245
- }),
1246
- };
1247
- const ws = yield automation_1.LocalWorkspace.create({ pulumiCommand: mockCommand });
1248
- yield ws.install();
1249
- assert_1.default.deepStrictEqual(recordedArgs, ["install"]);
1250
- yield ws.install({ noPlugins: true });
1251
- assert_1.default.deepStrictEqual(recordedArgs, ["install", "--no-plugins"]);
1252
- yield ws.install({ noDependencies: true });
1253
- assert_1.default.deepStrictEqual(recordedArgs, ["install", "--no-dependencies"]);
1254
- yield ws.install({ reinstall: true });
1255
- assert_1.default.deepStrictEqual(recordedArgs, ["install", "--reinstall"]);
1256
- yield ws.install({ useLanguageVersionTools: true });
1257
- assert_1.default.deepStrictEqual(recordedArgs, ["install", "--use-language-version-tools"]);
1258
- yield ws.install({
1259
- noDependencies: true,
1260
- noPlugins: true,
1261
- reinstall: true,
1262
- useLanguageVersionTools: true,
1263
- });
1264
- assert_1.default.deepStrictEqual(recordedArgs, [
1265
- "install",
1266
- "--use-language-version-tools",
1267
- "--no-plugins",
1268
- "--no-dependencies",
1269
- "--reinstall",
1270
- ]);
1271
- }));
1272
- it(`install requires version >= 3.91`, () => __awaiter(void 0, void 0, void 0, function* () {
1273
- const mockCommand = {
1274
- command: "pulumi",
1275
- version: semver.parse("3.90.0"),
1276
- run: (args, cwd, additionalEnv, onOutput) => __awaiter(void 0, void 0, void 0, function* () {
1277
- return new automation_1.CommandResult("some output", "", 0);
1278
- }),
1279
- };
1280
- const ws = yield automation_1.LocalWorkspace.create({ pulumiCommand: mockCommand });
1281
- assert_1.default.rejects(() => ws.install());
1282
- }));
1283
- it(`install --use-language-version-tools requires version >= 3.130`, () => __awaiter(void 0, void 0, void 0, function* () {
1284
- const mockCommand = {
1285
- command: "pulumi",
1286
- version: semver.parse("3.129.0"),
1287
- run: (args, cwd, additionalEnv, onOutput) => __awaiter(void 0, void 0, void 0, function* () {
1288
- return new automation_1.CommandResult("some output", "", 0);
1289
- }),
1290
- };
1291
- const ws = yield automation_1.LocalWorkspace.create({ pulumiCommand: mockCommand });
1292
- assert_1.default.rejects(() => ws.install());
1293
- }));
1294
- it("sends SIGINT when aborted", () => __awaiter(void 0, void 0, void 0, function* () {
1295
- const controller = new AbortController();
1296
- const program = () => __awaiter(void 0, void 0, void 0, function* () {
1297
- yield new Promise((f) => setTimeout(f, 60000));
1298
- return {};
1299
- });
1300
- const projectName = "inline_node";
1301
- const stackName = automation_1.fullyQualifiedStackName(util_1.getTestOrg(), projectName, `int_test${util_1.getTestSuffix()}`);
1302
- const stack = yield automation_1.LocalWorkspace.createStack({ stackName, projectName, program });
1303
- new Promise((f) => setTimeout(f, 1000)).then(() => controller.abort());
1304
- try {
1305
- // pulumi preview
1306
- const previewRes = yield stack.preview({
1307
- signal: controller.signal,
1308
- });
1309
- assert_1.default.fail("expected canceled preview to throw");
1310
- }
1311
- catch (err) {
1312
- assert_1.default.match(err.toString(), /stderr: Command was killed with SIGINT/);
1313
- assert_1.default.match(err.toString(), /CommandError: code: -2/);
1314
- }
1315
- yield stack.workspace.removeStack(stackName);
1316
- }));
1317
- });
1318
- const normalizeConfigKey = (key, projectName) => {
1319
- const parts = key.split(":");
1320
- if (parts.length < 2) {
1321
- return `${projectName}:${key}`;
1322
- }
1323
- return "";
1324
- };
1325
- //# sourceMappingURL=localWorkspace.spec.js.map