我有兴趣根据某些条件向 GO 模板添加内容。我有一个这样定义的结构 -
{
"resourceActions": {
"update": {
"input": null,
"output": "instance",
},
"stop": {
"input": "instanceStop",
"output": "instance",
},
"console": {
"input": "instanceConsoleInput",
"output": "instanceConsole",
},
"restart": {
"input": null,
"output": "instance",
},
"remove": {
"input": null,
"output": "instance",
},
}
我需要遍历“resourceActions”,如果在其中定义的操作(如更新、重启等)的输入为 null,则生成“A()”,否则生成 A(输入 *{inputVAL})
例子 -
{
for Update - A()
for stop - A(input *instanceStop)
for console - A(input *instanceConsoleInput)
for restart - A()
}
我如何在 GO-tempaltes 中做到这一点