Search code examples
kuberneteskubernetes-helm

yaml parse error


When i run the helm install command the below line gives me the error:

args: [while [ 1 ]; do echo "hi" ; sleep 1; done;]

Error:

Error: YAML parse error 
converting YAML to JSON: yaml: line 27: did not find expected ',' or ']'

Solution

  • Square brackets have special meaning in YAML (they indicate a flow sequence, i.e. an inline array). You need to quote that scalar (string):

    args: [ 'while [ 1 ]; do echo "I am awake" ; sleep 1; done;' ]
    

    ...or make it a block scalar and use the literal indicator, |:

    args:
      - |
        while [ 1 ]; do echo "I am awake" ; sleep 1; done;
    

    Both of these produce the same JSON:

    {
      "args": [
        "while [ 1 ]; do echo \"I am awake\" ; sleep 1; done;"
      ]
    }