Skip to content

Commit 5f932a9

Browse files
authored
Merge pull request #150 from glennsarti/add-debug-adapter
(GH-100) Add debug adapter
2 parents 5a7dce2 + ab7c89f commit 5f932a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3739
-418
lines changed

client/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Create or open any Puppet manifest with the extension `.pp` or `.epp` and the ex
3737
- Import from `puppet resource` directly into manifests
3838
- Node graph preview
3939
- Puppet Development Kit integration
40+
- (Experimental) Local debugging of Puppet manifests
4041

4142
## Feature information
4243

@@ -99,6 +100,32 @@ To use any of the above commands, open the command palette and start typing a co
99100

100101
`PDK New Module` is available even if the extension isn't loaded, the rest of the commands are only available when the extension is loaded.
101102

103+
### Locally debugging Puppet manifests
104+
105+
**Note - This is an experimental feature**
106+
107+
The Puppet extension is able to debug the compilation of a Puppet manifest, much like a Go, PowerShell, C# etc. The debugger supports:
108+
109+
* Line breakpoints but not conditions on those breakpoints
110+
* Function breakpoints
111+
* Exception breakpoints
112+
* Call stack
113+
* Variables, but only at the top stack frame
114+
* Limited interactive debug console. For example, you can assign a variable a value, but just as in regular Puppet you can't change its value later
115+
* Step In, Out, Over
116+
117+
You may be presented with a Launch Configuration on first use. Please see the [VSCode Debugging link](https://code.visualstudio.com/docs/editor/debugging) for instructions on how to set this up.
118+
119+
Settings:
120+
121+
`manifest` - The manifest to apply. By default this is the currently open file in the editor
122+
123+
`noop` - Whether the `puppet apply` sets No Operation (Noop) mode. By default, this is set to false. This means when runing the debugger it can make changes to your system
124+
125+
`args` - Additional arguements to pass to `puppet apply`, for example `['--debug']` will output debug information
126+
127+
![Puppet Debug Adapter](https://raw.githubusercontent.com/jpogran/puppet-vscode/master/client/docs/assets/puppet_debug.gif)
128+
102129
## Installing the Extension
103130

104131
You can install the official release of the Puppet extension by following the steps
538 KB
Loading

client/gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ gulp.task('clean', function () {
1616
gulp.task('copy_language_server', function () {
1717
return gulp.src(['../server/lib/**/*',
1818
'../server/vendor/**/*',
19+
'../server/puppet-debugserver',
1920
'../server/puppet-languageserver'
2021
], { base: '../server'})
2122
.pipe(gulp.dest('./vendor/languageserver'));

client/package.json

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"Linters",
2828
"Languages",
2929
"Snippets",
30-
"Formatters"
30+
"Formatters",
31+
"Debuggers"
3132
],
3233
"keywords": [
3334
"puppet",
@@ -309,7 +310,70 @@
309310
"description": "The fully qualified path to the Puppet agent install directory. For example: 'C:\\Program Files\\Puppet Labs\\Puppet' or '/opt/puppetlabs/puppet'"
310311
}
311312
}
312-
}
313+
},
314+
"breakpoints": [
315+
{
316+
"language": "puppet"
317+
}
318+
],
319+
"debuggers": [
320+
{
321+
"type": "Puppet",
322+
"label": "Puppet Debugger",
323+
"program": "./out/src/debugAdapter.js",
324+
"runtime": "node",
325+
"languages": [
326+
"puppet"
327+
],
328+
"configurationSnippets": [
329+
{
330+
"label": "Puppet: Apply Current File",
331+
"description": "Apply current file (in active editor window) under debugger",
332+
"body": {
333+
"type": "Puppet",
334+
"request": "launch",
335+
"name": "Puppet Apply current file",
336+
"manifest": "^\"\\${file}\"",
337+
"args": [],
338+
"noop": false,
339+
"cwd": "^\"\\${file}\""
340+
}
341+
}
342+
],
343+
"configurationAttributes": {
344+
"launch": {
345+
"properties": {
346+
"program": {
347+
"type": "string",
348+
"description": "Deprecated. Please use the 'manifest' property instead to specify the absolute path to the Puppet manifest to launch under the debugger."
349+
},
350+
"manifest": {
351+
"type": "string",
352+
"description": "Optional: Absolute path to the Puppet manifest to launch under the debugger."
353+
},
354+
"noop": {
355+
"type": "boolean",
356+
"description": "Optional: Whether the the Puppet run is in NoOp mode. Default is false.",
357+
"default": false
358+
},
359+
"args": {
360+
"type": "array",
361+
"description": "Command line arguments to pass to Puppet.",
362+
"items": {
363+
"type": "string"
364+
},
365+
"default": []
366+
},
367+
"cwd": {
368+
"type": "string",
369+
"description": "Absolute path to the working directory. Default is the current workspace.",
370+
"default": "${workspaceRoot}"
371+
}
372+
}
373+
}
374+
}
375+
}
376+
]
313377
},
314378
"scripts": {
315379
"vscode:prepublish": "node node_modules/gulp/bin/gulp.js build",
@@ -333,6 +397,8 @@
333397
"dependencies": {
334398
"vscode-languageclient": "~3.3.0",
335399
"vscode-extension-telemetry": "^0.0.6",
336-
"viz.js":"~1.8.0"
400+
"viz.js":"~1.8.0",
401+
"vscode-debugprotocol": "^1.19.0",
402+
"vscode-debugadapter": "^1.19.0"
337403
}
338404
}

client/src/commands/pdk/pdkNewClassCommand.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import * as vscode from 'vscode';
44
import * as cp from 'child_process';
55
import ChildProcess = cp.ChildProcess;
6-
import { Logger } from '../../logging';
6+
import { ILogger } from '../../logging';
77
import { reporter } from '../../telemetry/telemetry';
88
import * as messages from '../../messages';
99

1010
export class pdkNewClassCommand {
11-
private logger: Logger = undefined;
11+
private logger: ILogger = undefined;
1212
private terminal: vscode.Terminal = undefined;
1313

14-
constructor(logger: Logger, terminal: vscode.Terminal) {
14+
constructor(logger: ILogger, terminal: vscode.Terminal) {
1515
this.logger = logger;
1616
this.terminal = terminal;
1717
}

client/src/commands/pdk/pdkNewModuleCommand.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use strict';
22

33
import * as vscode from 'vscode';
4-
import { Logger } from '../../logging';
4+
import { ILogger } from '../../logging';
55
import { reporter } from '../../telemetry/telemetry';
66
import * as messages from '../../messages';
77

88
export class pdkNewModuleCommand {
9-
private logger: Logger = undefined;
9+
private logger: ILogger = undefined;
1010
private terminal: vscode.Terminal = undefined;
1111

12-
constructor(logger: Logger, terminal: vscode.Terminal) {
12+
constructor(logger: ILogger, terminal: vscode.Terminal) {
1313
this.logger = logger;
1414
this.terminal = terminal;
1515
}

client/src/commands/pdk/pdkTestCommand.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import * as vscode from 'vscode';
44
import * as cp from 'child_process';
55
import ChildProcess = cp.ChildProcess;
6-
import { Logger } from '../../logging';
6+
import { ILogger } from '../../logging';
77
import { reporter } from '../../telemetry/telemetry';
88
import * as messages from '../../messages';
99

1010
export class pdkTestUnitCommand {
11-
private logger: Logger = undefined;
11+
private logger: ILogger = undefined;
1212
private terminal: vscode.Terminal = undefined;
1313

14-
constructor(logger: Logger, terminal: vscode.Terminal) {
14+
constructor(logger: ILogger, terminal: vscode.Terminal) {
1515
this.logger = logger;
1616
this.terminal = terminal;
1717
}

client/src/commands/pdk/pdkValidateCommand.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import * as vscode from 'vscode';
44
import * as cp from 'child_process';
55
import ChildProcess = cp.ChildProcess;
6-
import { Logger } from '../../logging';
6+
import { ILogger } from '../../logging';
77
import { reporter } from '../../telemetry/telemetry';
88
import * as messages from '../../messages';
99

1010
export class pdkValidateCommand {
11-
private logger: Logger = undefined;
11+
private logger: ILogger = undefined;
1212
private terminal: vscode.Terminal = undefined;
1313

14-
constructor(logger: Logger, terminal: vscode.Terminal) {
14+
constructor(logger: ILogger, terminal: vscode.Terminal) {
1515
this.logger = logger;
1616
this.terminal = terminal;
1717
}

client/src/commands/pdkcommands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import * as vscode from 'vscode';
22
import * as messages from '../../src/messages';
33
import { IConnectionManager } from '../../src/connection';
4-
import { Logger } from '../../src/logging';
4+
import { ILogger } from '../../src/logging';
55
import { pdkNewModuleCommand } from './pdk/pdkNewModuleCommand';
66
import { pdkNewClassCommand } from './pdk/pdkNewClassCommand';
77
import { pdkNewTaskCommand } from './pdk/pdkNewTaskCommand';
88
import { pdkValidateCommand } from './pdk/pdkValidateCommand';
99
import { pdkTestUnitCommand } from './pdk/pdkTestCommand';
1010

11-
export function setupPDKCommands(langID: string, connManager: IConnectionManager, ctx: vscode.ExtensionContext, logger: Logger, terminal: vscode.Terminal) {
11+
export function setupPDKCommands(langID: string, connManager: IConnectionManager, ctx: vscode.ExtensionContext, logger: ILogger, terminal: vscode.Terminal) {
1212
let newModuleCommand = new pdkNewModuleCommand(logger, terminal);
1313
ctx.subscriptions.push(newModuleCommand);
1414
ctx.subscriptions.push(vscode.commands.registerCommand(messages.PDKCommandStrings.PdkNewModuleCommandId, () => {

client/src/commands/puppet/puppetResourceCommand.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use strict';
22

33
import * as vscode from 'vscode';
4-
import { IConnectionManager, ConnectionStatus } from '../../connection';
5-
import { Logger } from '../../logging';
4+
import { ConnectionStatus } from '../../interfaces';
5+
import { IConnectionManager } from '../../connection';
6+
import { ILogger } from '../../logging';
67
import { reporter } from '../../telemetry/telemetry';
78
import * as messages from '../../messages';
89

@@ -13,9 +14,9 @@ class RequestParams implements messages.PuppetResourceRequestParams {
1314

1415
export class puppetResourceCommand {
1516
private _connectionManager: IConnectionManager = undefined;
16-
private logger: Logger = undefined;
17+
private logger: ILogger = undefined;
1718

18-
constructor(connMgr: IConnectionManager, logger: Logger) {
19+
constructor(connMgr: IConnectionManager, logger: ILogger) {
1920
this._connectionManager = connMgr;
2021
this.logger = logger;
2122
}

0 commit comments

Comments
 (0)