rozpuszczalny / vscode-redmine

Redmine extension for Visual Studio Code.
MIT License
43 stars 17 forks source link

New version does not support devcontainer environmental variables. #28

Closed jonfen closed 4 years ago

jonfen commented 4 years ago

So that we don't commit a redmine API key to git, it is nice to leverage the .env option when using devcontainers with docker-compose.

https://code.visualstudio.com/docs/remote/containers-advanced#_option-2-use-an-env-file https://code.visualstudio.com/docs/remote/devcontainerjson-reference#_variables-in-devcontainerjson

.env

REDMINE_API_KEY=4asd9na345lkjnc9d8934n5

docker-compose.vscode.yml

version: "3.7"
  services:
    gibson:
      environment:
      - REDMINE_API_KEY

.devcontainer.json

...
"dockerComposeFile": [
        "docker-compose.vscode.yml"
],
"extensions": [
    "rozpuszczalny.vscode-redmine"
],
"settings": {
    "redmine.apiKey": "${remoteEnv:REDMINE_API_KEY}",
    "redmine.identifier": "ProjectName",
    "redmine.url": "https://redmine.domain.com/"
}   
"remoteEnv": {
    "REDMINE_API_KEY": "${containerEnv:REDMINE_API_KEY}"
}

Inside the container echo $REDMINE_API_KEY exports 4asd9na345lkjnc9d8934n5 Hardcoding"redmine.apiKey": "4asd9na345lkjnc9d8934n5" also works

rozpuszczalny commented 4 years ago

Hi, thanks for raising this issue.

First, I'll have to dig into devcontainers, to see how it works - I never had a chance to work with devcontainers. I'll then try to see what my extension needs to cover to work with devcontainers.

jonfen commented 4 years ago

Related to #29

jonfen commented 4 years ago

Hi, thanks for raising this issue.

First, I'll have to dig into devcontainers, to see how it works - I never had a chance to work with devcontainers. I'll then try to see what my extension needs to cover to work with devcontainers.

Let me know if I can help.

Working Examples: https://github.com/search?q=org%3Amicrosoft+vscode-remote-try-&type=Repositories Docs: https://code.visualstudio.com/docs/remote/containers

rozpuszczalny commented 4 years ago

Hi @jonfen,

I dig it a little bit and I think using containerEnv or remoteEnv inside settings is not supported by VSCode itself. I even tried to use ${env:ENV_VARIABLE} with local workspace and that didn't work as well. I think it's related to this issue: https://github.com/microsoft/vscode/issues/2809 .

So unfortunately, I really cannot do anything to make it work the way you want to.

If you'll find any extension, which is working with referencing environment variables, please repoen this issue and link it here, so I'll dig it more :wink: