当我运行helm install命令时,下面的行给出了错误:
var str = "1, 'str,ing', [1, 2, [3, 4, 5, 'str,ing']], 'st[rin,g]['";
var start_index = 0;
var parts = [];
for(index=0; index<str.length; index++) {
// Single quote blocks
if(str.charAt(index) == "'") {
while(str.charAt(++index) != "'" && index < str.length);
} else
// Double quote blocks
if(str.charAt(index) == '"') {
while(str.charAt(++index) != '"' && index < str.length);
} else
// array blocks
if(str.charAt(index) == '[') {
var depth = 1;
while(depth != 0 && index < str.length) {
index++;
if(str.charAt(index) == '[') depth++;
if(str.charAt(index) == ']') depth--;
}
} else if(str.charAt(index) == ',') {
parts.push(str.substring(start_index, index).trim());
start_index = index+1;
}
}
parts.push(str.substring(start_index).trim());
console.log(parts)
错误:
args: [while [ 1 ]; do echo "hi" ; sleep 1; done;]
答案 0 :(得分:1)
方括号在YAML中具有特殊含义(它们表示流序列,即内联数组)。你需要引用那个标量(字符串):
args: [ 'while [ 1 ]; do echo "I am awake" ; sleep 1; done;' ]
...或使其成为块标量并使用文字指示符|
:
args:
- |
while [ 1 ]; do echo "I am awake" ; sleep 1; done;
{
"args": [
"while [ 1 ]; do echo \"I am awake\" ; sleep 1; done;"
]
}