cdrx / rancher-gitlab-deploy

Painless deployment of projects built with GitLab CI onto your Rancher infrastructure
MIT License
432 stars 89 forks source link

Trim env. variable names before passing them to Rancher #71

Open dimw opened 3 years ago

dimw commented 3 years ago

Actual behaviour: When passing multiple variables alongside with the --variables multiline configuration might be used:

deploy:
  stage: deploy
  image: cdrx/rancher-gitlab-deploy
  script:
    - >
       upgrade
       --variables "
       DB_HOST=db.example.com,
       DB_USER=foo,
       DB_PASSWORD=bar
       "

Which result in the following command after YAML is processed:

upgrade --variables " DB_HOST=db.example.com, DB_USER=foo, DB_PASSWORD=bar"

Due to the current string splitting logic, the spaces before the env variables become a part of the variable passed to Rancher (1.6.30) which result in an invalid env variable which appears in the Rancher UI (e.g. <space>DB_HOST, incl. the space) but is not passed to the container.

Expected outcome: Variable names and values are trimmed when passing as string with --variables option.