haproxytech / dataplaneapi

HAProxy Data Plane API
https://www.haproxy.com/documentation/dataplaneapi/
Apache License 2.0
325 stars 75 forks source link

Config files don't support environment variables #268

Open mdtomo opened 2 years ago

mdtomo commented 2 years ago

I've tried adding environment variables to my config but it appears they aren't parsed. Example below for a sample yml config. The environment variables work correctly in haproxy.cfg as I tested this by putting the value for $PASSWORD directly into thedataplaneapi.yml config. I tried this with the hcl config type declaring a variable block but parsing failed on the line where type is declared.

variable "password" {
  type = string
}

Throws error unknown token: 6:10 IDENT string

dataplaneapi.yml

name: famous_condor
dataplaneapi:
  host: 0.0.0.0
  port: 8080
  user:
  - name: admin
    insecure: true
    password: ${PASSWORD}
  resources:
    maps_dir: /etc/haproxy/maps
    ssl_certs_dir: /etc/haproxy/ssl
    spoe_dir: /etc/haproxy/spoe
haproxy:
  config_file: /etc/haproxy/haproxy.cfg
  haproxy_bin: /usr/local/sbin/haproxy
  reload:
    reload_cmd: kill -SIGUSR2 1
    restart_cmd: kill -SIGUSR2 1

haproxy.cfg

userlist proxy-userlist
    user admin insecure-password "$PASSWORD"

I'm assuming environment variables in dataplane api config files aren't currently supported?

mjuraga commented 1 year ago

Currently we are not supporting env variables in the config files. We can put that as a feature request.