yaml parse error

4/18/2018

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 ']'
-- hmims
kubernetes
kubernetes-helm

1 Answer

4/18/2018

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;"
  ]
}
-- Jordan Running
Source: StackOverflow