envplate icon indicating copy to clipboard operation
envplate copied to clipboard

Recursive substitution?

Open djarbz opened this issue 3 years ago • 7 comments

I would like to put substitutions on the right hand side of the :, or a better solution would be great too.

Expected Behavior

tunnel_host = "${SERVER_TUNNEL_HOST:-${SERVER_URL:-http://$(hostname)}}" would render in this precedence:

  1. SERVER_TUNNEL_HOST
  2. SERVER_URL
  3. http://hostname

Actual Behavior

tunnel_host = "${SERVER_URL:-http://$(hostname)}"

Steps to Reproduce (including precondition)

SERVER_TUNNEL_HOST is unset
SERVER_URL=http://my.server.com
tunnel_host = "${SERVER_TUNNEL_HOST:-${SERVER_URL:-http://$(hostname)}}"

renders tunnel_host = "${SERVER_URL:-http://$(hostname)}"

Your Environment

  • OS: docker.io/debian:11
  • envplate version: 1.0.2

Another scenario

auth = "${SERVER_AUTH_USER:?${SERVER_AUTH_PASSWORD:?${SERVER_AUTH_USER}:${SERVER_AUTH_PASSWORD}}}" This should verify that SERVER_AUTH_USER & SERVER_AUTH_PASSWORD are both set, then set the line to the value of: auth = "${SERVER_AUTH_USER}:${SERVER_AUTH_PASSWORD"

djarbz avatar Jul 20 '22 17:07 djarbz

@djarbz Have you ever been able to find a solution for this ?

di-rect avatar Dec 30 '23 15:12 di-rect

Unfortunately I have not.

djarbz avatar Dec 30 '23 15:12 djarbz

@djarbz that's a pity, I'm looking for a workaround too. Have you tried escaping and such like the empty value needs as well ?

di-rect avatar Dec 30 '23 16:12 di-rect

I haven't touched this in quite some time, I don't even recall what project I was wanting this for.

djarbz avatar Dec 30 '23 16:12 djarbz

@djarbz OK understood; in other cases you need to go thought your files using AWK or SED so it's pretty useful!

di-rect avatar Dec 30 '23 16:12 di-rect

@mavogel Is this something you might can look into ?

di-rect avatar Dec 30 '23 19:12 di-rect

are you expecting hostname also to be substituted?

A single replacement in the default might be easy with a more complex regular expression and some logic. But multiple and especially nested ones are very difficult in regexp

enc avatar Dec 30 '23 22:12 enc