argocd-vault-plugin icon indicating copy to clipboard operation
argocd-vault-plugin copied to clipboard

Unicode and Traling spaces parsing issue, multilines compressed into 1 line

Open ironoa opened this issue 1 year ago • 1 comments

There might be an issue with the generate/parsing of Unicode characters and trailing spaces inside multiline sections, for example:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: name
  source:
    repoURL: https://yourChart
    chart: chartName  
    plugin:
      env:
        - name: HELM_VALUES
          value: |
            test1: 'test1'
            test2: test2

Produces (Correctly)

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: name
  source:
    chart: chartName
    plugin:
      env:
      - name: HELM_VALUES
        value: |
          test1: test1
          test2: test2
    repoURL: https://yourChart

while

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: name
  source:
    repoURL: https://yourChart
    chart: chartName  
    plugin:
      env:
        - name: HELM_VALUES
          value: |
            test1: 'test2🍀'
            test2: test2

Produces (Wrongly, due to an Unicode inside the multiline section)

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: name
  source:
    chart: chartName
    plugin:
      env:
      - name: HELM_VALUES
        value: "test1: test2\U0001F340\ntest2: test2\n"
    repoURL: https://yourChart

and

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: name
  source:
    repoURL: https://yourChart
    chart: chartName  
    plugin:
      env:
        - name: HELM_VALUES
          value: |
            test1: 'test2 '
            test2: test2

Produces (Wrongly, due to a trailing space inside the multiline section )

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: "name\U0001F340"
  source:
    chart: chartName
    plugin:
      env:
      - name: HELM_VALUES
        value: "test1: test2 \ntest2: test2"
    repoURL: https://yourChart

So, multilines get compressed into a single line. A workaround is to filter out them before the generate/parsing command applies:

... | sed 's/[^\x00-\x7F]//g' | sed 's/[ \t]*$//' | argocd-vault-plugin generate -

What is the cause of this issue ? can it be fixed ?

Thanks

ironoa avatar May 22 '23 11:05 ironoa

Another way to reproduce the error is by updating the test files

  1. Update "input/nonempty/deployment.yaml" with the following "env" values at the bottom of the file and update "output/all.yaml"
env:
  - name: HELM_VALUES
    value: |
       test1: "test2🍀"
  1. Run test
go test -v cmd/*
  1. the rendered manifest, see below, is not aligned with the expected result:
env:
  – name: HELM_VALUES
    value: "test: \"\U0001F340\"\n"

benjwi avatar May 22 '23 15:05 benjwi