@pulumi/pulumi
Advanced tools
Comparing version 3.118.1-alpha.xe63ff72 to 3.119.0-alpha.xf598962
@@ -320,6 +320,8 @@ import { PulumiCommand } from "./cmd"; | ||
/** | ||
* Returns all Stacks created under the current Project. | ||
* Returns all Stacks from the underlying backend based on the provided options. | ||
* This queries underlying backend and may return stacks not present in the Workspace (as Pulumi.<stack>.yaml files). | ||
* | ||
* @param opts Options to customize the behavior of the list. | ||
*/ | ||
listStacks(): Promise<StackSummary[]>; | ||
listStacks(opts?: ListOptions): Promise<StackSummary[]>; | ||
/** | ||
@@ -458,1 +460,7 @@ * Installs a plugin in the Workspace, for example to use cloud providers like AWS or GCP. | ||
} | ||
export interface ListOptions { | ||
/** | ||
* List all stacks instead of just stacks for the current project | ||
*/ | ||
all?: boolean; | ||
} |
@@ -630,8 +630,16 @@ "use strict"; | ||
/** | ||
* Returns all Stacks created under the current Project. | ||
* Returns all Stacks from the underlying backend based on the provided options. | ||
* This queries underlying backend and may return stacks not present in the Workspace (as Pulumi.<stack>.yaml files). | ||
* | ||
* @param opts Options to customize the behavior of the list. | ||
*/ | ||
listStacks() { | ||
listStacks(opts) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const result = yield this.runPulumiCmd(["stack", "ls", "--json"]); | ||
const args = ["stack", "ls", "--json"]; | ||
if (opts) { | ||
if (opts.all) { | ||
args.push("--all"); | ||
} | ||
} | ||
const result = yield this.runPulumiCmd(args); | ||
return JSON.parse(result.stdout); | ||
@@ -638,0 +646,0 @@ }); |
import { PulumiCommand } from "./cmd"; | ||
import { ConfigMap, ConfigValue } from "./config"; | ||
import { ListOptions } from "./localWorkspace"; | ||
import { ProjectSettings } from "./projectSettings"; | ||
@@ -218,6 +219,8 @@ import { OutputMap } from "./stack"; | ||
/** | ||
* Returns all Stacks created under the current Project. | ||
* This queries underlying backend and may return stacks not present in the Workspace (as Pulumi.<stack>.yaml files). | ||
* Returns all Stacks from the underlying backend based on the provided options. | ||
* This queries backend and may return stacks not present in the Workspace (as Pulumi.<stack>.yaml files). | ||
* | ||
* @param opts Options to customize the behavior of the list. | ||
*/ | ||
listStacks(): Promise<StackSummary[]>; | ||
listStacks(opts?: ListOptions): Promise<StackSummary[]>; | ||
/** | ||
@@ -224,0 +227,0 @@ * Installs a plugin in the Workspace, for example to use cloud providers like AWS or GCP. |
{ | ||
"name": "@pulumi/pulumi", | ||
"version": "3.118.1-alpha.xe63ff72", | ||
"version": "3.119.0-alpha.xf598962", | ||
"description": "Pulumi's Node.js SDK", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -146,2 +146,100 @@ "use strict"; | ||
}); | ||
describe("ListStack Methods", () => __awaiter(void 0, void 0, void 0, function* () { | ||
describe("ListStacks", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const stackJson = `[ | ||
{ | ||
"name": "testorg1/testproj1/teststack1", | ||
"current": false, | ||
"url": "https://app.pulumi.com/testorg1/testproj1/teststack1" | ||
}, | ||
{ | ||
"name": "testorg1/testproj1/teststack2", | ||
"current": false, | ||
"url": "https://app.pulumi.com/testorg1/testproj1/teststack2" | ||
} | ||
]`; | ||
it(`should handle stacks correctly for listStacks`, () => __awaiter(void 0, void 0, void 0, function* () { | ||
const mockWithReturnedStacks = { | ||
command: "pulumi", | ||
version: null, | ||
run: (args, cwd, additionalEnv) => __awaiter(void 0, void 0, void 0, function* () { | ||
return new automation_1.CommandResult(stackJson, "", 0); | ||
}), | ||
}; | ||
const workspace = yield automation_1.LocalWorkspace.create({ pulumiCommand: mockWithReturnedStacks }); | ||
const stacks = yield workspace.listStacks(); | ||
assert_1.default.strictEqual(stacks.length, 2); | ||
assert_1.default.strictEqual(stacks[0].name, "testorg1/testproj1/teststack1"); | ||
assert_1.default.strictEqual(stacks[0].current, false); | ||
assert_1.default.strictEqual(stacks[0].url, "https://app.pulumi.com/testorg1/testproj1/teststack1"); | ||
assert_1.default.strictEqual(stacks[1].name, "testorg1/testproj1/teststack2"); | ||
assert_1.default.strictEqual(stacks[1].current, false); | ||
assert_1.default.strictEqual(stacks[1].url, "https://app.pulumi.com/testorg1/testproj1/teststack2"); | ||
})); | ||
it(`should use correct args for listStacks`, () => __awaiter(void 0, void 0, void 0, function* () { | ||
let capturedArgs = []; | ||
const mockPulumiCommand = { | ||
command: "pulumi", | ||
version: null, | ||
run: (args, cwd, additionalEnv) => __awaiter(void 0, void 0, void 0, function* () { | ||
capturedArgs = args; | ||
return new automation_1.CommandResult(stackJson, "", 0); | ||
}), | ||
}; | ||
const workspace = yield automation_1.LocalWorkspace.create({ | ||
pulumiCommand: mockPulumiCommand, | ||
}); | ||
yield workspace.listStacks(); | ||
assert_1.default.deepStrictEqual(capturedArgs, ["stack", "ls", "--json"]); | ||
})); | ||
})); | ||
describe("ListStacks with all", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const stackJson = `[ | ||
{ | ||
"name": "testorg1/testproj1/teststack1", | ||
"current": false, | ||
"url": "https://app.pulumi.com/testorg1/testproj1/teststack1" | ||
}, | ||
{ | ||
"name": "testorg1/testproj2/teststack2", | ||
"current": false, | ||
"url": "https://app.pulumi.com/testorg1/testproj2/teststack2" | ||
} | ||
]`; | ||
it(`should handle stacks correctly for listStacks when all is set`, () => __awaiter(void 0, void 0, void 0, function* () { | ||
const mockWithReturnedStacks = { | ||
command: "pulumi", | ||
version: null, | ||
run: () => __awaiter(void 0, void 0, void 0, function* () { return new automation_1.CommandResult(stackJson, "", 0); }), | ||
}; | ||
const workspace = yield automation_1.LocalWorkspace.create({ | ||
pulumiCommand: mockWithReturnedStacks, | ||
}); | ||
const stacks = yield workspace.listStacks({ all: true }); | ||
assert_1.default.strictEqual(stacks.length, 2); | ||
assert_1.default.strictEqual(stacks[0].name, "testorg1/testproj1/teststack1"); | ||
assert_1.default.strictEqual(stacks[0].current, false); | ||
assert_1.default.strictEqual(stacks[0].url, "https://app.pulumi.com/testorg1/testproj1/teststack1"); | ||
assert_1.default.strictEqual(stacks[1].name, "testorg1/testproj2/teststack2"); | ||
assert_1.default.strictEqual(stacks[1].current, false); | ||
assert_1.default.strictEqual(stacks[1].url, "https://app.pulumi.com/testorg1/testproj2/teststack2"); | ||
})); | ||
it(`should use correct args for listStacks when all is set`, () => __awaiter(void 0, void 0, void 0, function* () { | ||
let capturedArgs = []; | ||
const mockPuluiCommand = { | ||
command: "pulumi", | ||
version: null, | ||
run: (args, cwd, additionalEnv) => __awaiter(void 0, void 0, void 0, function* () { | ||
capturedArgs = args; | ||
return new automation_1.CommandResult(stackJson, "", 0); | ||
}), | ||
}; | ||
const workspace = yield automation_1.LocalWorkspace.create({ | ||
pulumiCommand: mockPuluiCommand, | ||
}); | ||
yield workspace.listStacks({ all: true }); | ||
assert_1.default.deepStrictEqual(capturedArgs, ["stack", "ls", "--json", "--all"]); | ||
})); | ||
})); | ||
})); | ||
it(`Environment functions`, function () { | ||
@@ -148,0 +246,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -1,1 +0,1 @@ | ||
export declare const version = "3.118.1"; | ||
export declare const version = "3.119.0"; |
@@ -16,3 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = "3.118.1-alpha.xe63ff72"; | ||
exports.version = "3.119.0-alpha.xf598962"; | ||
//# sourceMappingURL=version.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
14500951
127571