Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [Unreleased]

- Add support to multiple projects inside a workspace #34

## v0.3.0

- Ability to stop debugging #11
Expand Down
48 changes: 29 additions & 19 deletions src/iac/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const NEW_STACK_TEXT = 'Create a new stack...';
export function activate(context: vscode.ExtensionContext) {
// register configuration providers for 'pulumi' debug type
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('pulumi', new PulumiConfigurationProvider()));
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('pulumi', new PulumiDynamicConfigurationProvider(),
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('pulumi', new PulumiDynamicConfigurationProvider(),
vscode.DebugConfigurationProviderTriggerKind.Dynamic));

// register the debug adapter factory
Expand All @@ -27,7 +27,7 @@ async function pickStack(workspaceFolder: string, env?: { [key: string]: string;
},
});

const stackSelection = vscode.workspace.getConfiguration().get<string|undefined>('pulumi.debug.stackSelection');
const stackSelection = vscode.workspace.getConfiguration().get<string | undefined>('pulumi.debug.stackSelection');
if (stackSelection === 'automatic') {
const current = await ws.stack();
if (current) {
Expand All @@ -43,7 +43,7 @@ async function pickStack(workspaceFolder: string, env?: { [key: string]: string;
description: s.current ? `current` : ``,
detail: s.url,
};
}).concat({label: '', kind: vscode.QuickPickItemKind.Separator}).concat({ label: NEW_STACK_TEXT });
}).concat({ label: '', kind: vscode.QuickPickItemKind.Separator }).concat({ label: NEW_STACK_TEXT });

const picked = await vscode.window.showQuickPick(picks, {
placeHolder: 'Select a stack'
Expand Down Expand Up @@ -135,27 +135,37 @@ class PulumiDynamicConfigurationProvider implements vscode.DebugConfigurationPro
if (!folder) {
return [];
}
const pattern = new vscode.RelativePattern(folder, 'Pulumi.yaml');
const pattern = new vscode.RelativePattern(folder, '**/Pulumi.yaml');
return vscode.workspace.findFiles(pattern).then((uris) => {
if (uris.length === 0) {
return [];
}
return [
{
"type": "pulumi",
"request": "launch",
"name": "pulumi preview",
"command": "preview",
"workDir": "${workspaceFolder}"
},
{
"type": "pulumi",
"request": "launch",
"name": "pulumi up",
"command": "up",
"workDir": "${workspaceFolder}"
const configurations: DebugConfiguration[] = [];
for (const uri of uris) {
const folderPath = uri.fsPath.substring(0, uri.fsPath.lastIndexOf('/'));
const projectName = folderPath.substring(folderPath.lastIndexOf('/') + 1, folderPath.length);
var name = ` [${projectName}]`;
if (projectName === folder.name) {
name = "";
}
];
configurations.push(
{
"type": "pulumi",
"request": "launch",
"name": `pulumi preview${name}`,
"command": "preview",
"workDir": folderPath
},
{
"type": "pulumi",
"request": "launch",
"name": `pulumi up${name}`,
"command": "up",
"workDir": folderPath
}
);
}
return configurations;
});
}
}
Expand Down