I have a java project that I would like to debug. The project code assumes that certain variables pointing at running services in our remote debugging environment are present, and if they aren't, it will crash.
I'm trying to get debugging working in VSCode, so now the challenge is to get those secret vars from vault and populate them for my debugging session.
I've tried a few approaches, but nothing so far has worked. Below is an example of my latest effort. I tried to use the inputs
feature with a type of command
, but it seems that the only valid commands you can use are commands that extensions register with VSCode. I can't just run a shell command.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Local Debugging",
"type": "java",
"mainClass": "com.company.appname",
"request": "launch",
"env": {
"MYVARNAME": "${input:VARNAME}"
}
}
],
"inputs": [
{
"id": "VARNAME",
"type": "command",
"command": "program-to-execute",
"args": [
"-arg1",
"value1"
]
}
]
}
program-to-execute
is the name of a program I have on my local machine that does some custom stuff to eventually execute a read against vault at the path you give it as one of the args. But this approach failed because program-to-execute
is not a command registered with VSCode internally either by default or by an extension.
In my googling around I haven't found a way to execute an arbitrary shell command and use the result as an env var value for a debugging session.
Have a look at Tasks Shell Input and look at the useSingleResult
property
Possibility is to generate the data you want by a shell command in a file and return an empty string and then use Command Variable to read the file content as key-value, JSON or Yaml file