英文:
Is it possible to display the value of an environment variable in a Tyk Dashboard template file?
问题
I'm trying to reference an environment variable in Tyk Dashboard.
I set up a docker-compose.yaml
file containing environment variables:
version: '3.6'
services:
tyk-portal:
image: tykio/portal:v1.3.0
command: --bootstrap
ports:
- 3001:3001
environment:
- ...
- MY_VAR=someValue123
When I run docker-compose up
, I can navigate to the Tyk dashboard on localhost:3001
.
Inside Tyk's top_nav.tmp
template file, I'm now trying to display the value of my environment variable MY_VAR
.
I want to use something like this:
<p>
{{ .Env.MY_VAR }}
</p>
However, nothing is displayed. I cannot find a concrete example in the docs and I'm starting to wonder if referencing an environment variable inside a Tyk template file is at all possible.
英文:
I'm trying to reference an environment variable in Tyk Dashboard.
I set up a docker-compose.yaml
file containing environment variables:
version: '3.6'
services:
tyk-portal:
image: tykio/portal:v1.3.0
command: --bootstrap
ports:
- 3001:3001
environment:
- ...
- MY_VAR=someValue123
When I run docker-compose up
, I can navigate to the Tyk dashboard on localhost:3001
.
Inside Tyks top_nav.tmp
template file I'm now trying to display the value of my environment variable MY_VAR
.
I want use something like this:
<p>
{{ .Env.MY_VAR }}
</p>
However, nothing is displayed. I cannot find a concrete example in the docs and I'm starting to wonder if referencing an environment variable inside a Tyk template file is at all possible.
答案1
得分: 1
Tyk bundles the Sprig Library (v3) which has the env
function. Use it like this:
<p>
{{ env "MY_VAR" }}
</p>
英文:
Tyk bundles the Sprig Library (v3) which has the env
function. Use it like this:
<p>
{{ env "MY_VAR" }}
</p>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论