helm icon indicating copy to clipboard operation
helm copied to clipboard

How can i use nesting values ?

Open polRk opened this issue 6 years ago • 4 comments

image:
  registry: 
  repository: 
  tag: latest
  pullSecret: regcred

It doesn't work


      - name: Deploy to DigitalOcean Kubernetes
        uses: 'deliverybot/[email protected]'
        with:
          release: ''
          version: '${{ github.sha }}'
          namespace: 'default'
          chart: './helm'
          helm: helm3
          values: 
            image: 
              tag: "${{ github.sha }}"
        env:
          KUBECONFIG_FILE: $GITHUB_WORKSPACE/.kubeconfig

polRk avatar Dec 06 '19 08:12 polRk

@polRk what error are you seeing when you try this?

colinjfw avatar Dec 16 '19 16:12 colinjfw

Have you tried

          values: |
            image.tag: "${{ github.sha }}"

When setting values for helm on the command line you'd use --set image.tag=$GITHUB_SHA, maybe the same applies here too?

riker09 avatar Jun 05 '20 16:06 riker09

Have you tried

          values: |
            image.tag: "${{ github.sha }}"

When setting values for helm on the command line you'd use --set image.tag=$GITHUB_SHA, maybe the same applies here too?

I tried it and it is not working. fortunately, I found the way by putting it in JSON format instead of YAML.

          values: |
            {
              "image": {
                "tag": "${{ github.sha }}"
              }
            }

But it will be better if we can it to support YAML nested format.

This is my guest. The root cause of the problem comes from when you using this

          values: |
            image: 
              tag: "${{ github.sha }}"

It will remove space indent on the second line, so content in values.yml will look like this

image: 
tag: "abcdefg"

See my debug value to test this scenario here https://github.com/winggundamth/bookinfo-ratings/runs/2468832416. You will see the following to confirm my assumption that the space indent has been removed

Run deliverybot/helm@v1
  with:
    helm: helm3
    release: bookinfo-dev-ratings
    namespace: student169-bookinfo-dev
    chart: k8s/helm
    value-files: k8s/helm-values/values-bookinfo-dev-ratings.yaml
    values: extraEnv:
    COMMIT_SHA: de44bcca7d9a046fc3a625cbbc1006b949408b68
  
  env:
    ENV_NAME: dev
    KUBECONFIG: /home/runner/work/bookinfo-ratings/bookinfo-ratings/2f4bf7f5-da00-4f07-a59e-d7f69bbeb0a2

winggundamth avatar Apr 29 '21 16:04 winggundamth

Ah yes, the infamous multiline strings in YAML. Whenever I have to deal with this I head over to https://yaml-multiline.info/. But it looks like you are right and there is no way of keeping the indentation intact. Your solution is probably the only way to make this work. Thankfully YAML and JSON are compatible since YAML is a superset of JSON. This is explained in detail in this StackOverflow question (and answer).

riker09 avatar Apr 30 '21 06:04 riker09