0

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.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Patrick
  • 1,728
  • 2
  • 17
  • 30

1 Answers1

1

Tyk bundles the Sprig Library (v3) which has the env function. Use it like this:

<p>
{{ env "MY_VAR" }}
</p>
Zeke Lu
  • 6,349
  • 1
  • 17
  • 23