kongfig icon indicating copy to clipboard operation
kongfig copied to clipboard

Env Variable substitution in config.yml

Open mo-mughrabi opened this issue 8 years ago • 7 comments

Hello everyone,

kongfig is very cool, saved us tons of time, thank you. Is there a way to use env variable substitution from env variable in config.yml file?

mo-mughrabi avatar Nov 04 '17 13:11 mo-mughrabi

You can use the JS config files to use env variables. If you like to have the config in YAML then you can import the config in js config file and change what you need and use the JS config with kongfig.

CyExy avatar Nov 04 '17 15:11 CyExy

@CyExy could we avoid the use of JS config file and do ENV variable substitution directly on YAML file?

kstromeiraos avatar Nov 29 '17 09:11 kstromeiraos

+1 @kstromeiraos

mo-mughrabi avatar Nov 29 '17 10:11 mo-mughrabi

I can see how this would be useful. How would this look:

apis:
  - name: test
    ensure: present
    attributes:
      upstream_url: 'http://%env(HOST)%'
      hosts:
          - '%env(HOST)%'

So HOST=mockbin.com kongfig apply ... would produce

apis:
  - name: test
    ensure: present
    attributes:
      upstream_url: 'http://mockbin.com'
      hosts:
          - 'mockbin.com'

CyExy avatar Nov 29 '17 12:11 CyExy

Looks good. And what do you think about this?

apis:
  - name: test
    ensure: present
    attributes:
      upstream_url: http://$(HOST)
      hosts:
          - $(HOST)

This way it would be more similar to Compose variables substitution.

kstromeiraos avatar Nov 29 '17 18:11 kstromeiraos

That could work, although compose and JS template literals are both using curly braces so maybe ${HOST} rather than $(HOST)

CyExy avatar Nov 29 '17 21:11 CyExy

Hi @CyExy , is there some news about this feature?

kstromeiraos avatar Dec 30 '17 16:12 kstromeiraos