Giter Site home page Giter Site logo

replacetokens's People

Contributors

qetza avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

dustywill

replacetokens's Issues

Feature Request: Context-sensitive escaping in docker-compose env files

We are using the replacetokens task to (among other things) replace placeholders in env files for docker compose.
These files have very specific requirements on escaping.
Currently we are using the "Replace Tokens" task, but it does not currently support escaping in these env files.
I realize this is a very specific use-case, but it is not possible to cover it with the custom-escaping config, due to the context-sensitive nature of the escaping.

Do you think it makes sense to add special escaping for *.env files here?

Basically what we need is the bash script below, which works well (up to a few edge cases). A bash script in the pipeline does not have access to all the variables though, afaik.

# Generate sed s-command to replace one literal with another one.
# The key is assumed to contain only characters [A-Z_]
function sub() {
  KEY="$1"
  VALUE=$(printf '%s' "$2" | sed -e 's/[\|&]/\\&/g')
  printf 's|#{%s}#|%s|g' "$KEY" "$VALUE"
}

# - Single quoted values need to have single quotes escaped.
# - Double quoted values need to have double quotes and backslashes escaped.
# - Double- und unquoted values need to have the dollar sign escaped.
VALUE_SQ=$(printf "%s" "$VALUE" | sed -e "s|'|\\\\'|g")
VALUE_DQ=$(printf "%s" "$VALUE" | sed -e 's|\\|\\\\|g' -e 's|"|\\"|g' -e 's|\$|$$|g')
VALUE_UQ=$(printf "%s" "$VALUE" | sed -e 's|\$|$$|g')
sed -i \
  -e '/^[^=]*='\''/ '"$(sub "$KEY" "$VALUE_SQ")" \
  -e '/^[^=]*="/ '"$(sub "$KEY" "$VALUE_DQ")" \
  -e "$(sub "$KEY" "$VALUE_UQ")" \
  "$FILE"

Replacing token with environment variable not working

I have been trying to replace tokens in the file with the help of environment variables. Tokens are replaced with blank values.

As per README, tried using --variables '$VARS' to replace tokens with values from environment variables.

Logs:
image

Allow CLI to access env as variables

To simplify the use of environment variables as variables add a new parameter --use-env to initialize variables with all env variables:

  • parameter --variables will be optional if --use-env is specified
  • variables specified in --variables will override env variables if they have the same name

#15

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.