Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env Variable substitution in config.yml #96

Open
mo-mughrabi opened this issue Nov 4, 2017 · 7 comments
Open

Env Variable substitution in config.yml #96

mo-mughrabi opened this issue Nov 4, 2017 · 7 comments

Comments

@mo-mughrabi
Copy link

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?

@CyExy
Copy link
Contributor

CyExy commented Nov 4, 2017

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.

@kstromeiraos
Copy link

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

@mo-mughrabi
Copy link
Author

+1 @kstromeiraos

@CyExy
Copy link
Contributor

CyExy commented Nov 29, 2017

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'

@kstromeiraos
Copy link

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.

@CyExy
Copy link
Contributor

CyExy commented Nov 29, 2017

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

@kstromeiraos
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants