ipedrazas / drone-helm

Helm (Kubernetes) plugin for drone.io
MIT License
120 stars 90 forks source link

Variable substitution in Values parameter doesn't work with braces #99

Open BnMcG opened 5 years ago

BnMcG commented 5 years ago

After using the plugin this morning, I've found that if I add braces around my variables (as seen in the docs), then variable substitution does not work correctly (at least for values in the Values parameter).

Dropping the braces, leaving just $MYVARIABLE, instead of ${MYVARIABLE} does work, though. Having looked at the code and tests it seems both should be interchangeable, is this not the case?

The value I'm substituting is fetched from a Drone secret. My pipeline step looks something like this:

  - name: deploy-qa
    image: myrepo/drone-helm
    settings:
      chart: mycharts/chart
      skip_tls_verify: true
      debug: true
      release: app-qa
      namespace: qa
      helm_repos: mycharts=https://charts.domain
      client_only: true
      values: rabbitmq.uri=${RABBITMQ_URI},otherThing.uri="http://bla",rabbitmq.exchange="exchange",rabbitmq.bindingKey=#
    environment:
      RABBITMQ_URI:
        from_secret: RABBITMQ_URI
      API_SERVER:
        from_secret: API_SERVER
      KUBERNETES_TOKEN:
        from_secret: KUBERNETES_TOKEN
    when:
      event:
        - promote
      target:
        - qa

In the example above, ${RABBITMQ_URI} isn't substituted, but $RABBITMQ_URI is. In the debug logs, I can see -ReplVar: _RABBITMQ_URI => RABBITMQ_URI-- when I don't add braces, but this is missing with braces around the variable.

So far as I can tell, the variable name matches the regex that the plugin seems to use match environment variables, so I'm unsure why this isn't working. Is this the intended behaviour and I'm just misunderstanding?

I'm using Drone 1.2 with a version of the plugin built from the latest commit on master.