bmf-san / gondola

A YAML based golang reverse proxy
MIT License
7 stars 1 forks source link

Environment variable support in configuration files #47

Closed bmf-san closed 5 months ago

bmf-san commented 5 months ago

Description

I want to be able to use environment variables in configuration files.

Implement parsing when environment variables are included.

Describe the feature you'd like to request

proxy:
  port: {{ .env.Port }}
  read_header_timeout: 2000
  shutdown_timeout: 3000
  tls_cert_path: certificates/cert.pem
  tls_key_path: certificates/key.pem
  static_files:
    - path: /public/
      dir: ./public
upstreams:
  - host_name: backend1.local
    target: http://backend1:8081 # backend1 is the name of the container
  - host_name: backend2.local
    target: http://backend2:8082 # backend2 is the name of the container
log_level: 0 # Debug:-4 Info:0 Warn:4 Error:8

proxy:
  port: 443
  read_header_timeout: 2000
  shutdown_timeout: 3000
  tls_cert_path: certificates/cert.pem
  tls_key_path: certificates/key.pem
  static_files:
    - path: /public/
      dir: ./public
upstreams:
  - host_name: backend1.local
    target: http://backend1:8081 # backend1 is the name of the container
  - host_name: backend2.local
    target: http://backend2:8082 # backend2 is the name of the container
log_level: 0 # Debug:-4 Info:0 Warn:4 Error:8

Describe the solution you'd like

Consider ways such as parsing environment variables in YAML files, or preparing TPL and converting TPL to YAML.

bmf-san commented 5 months ago

This can be easily implemented using os.ExpandEnv.

cf. https://pkg.go.dev/os#example-ExpandEnv