Google cloud platform gcloud services enable/disable--async--format=json返回空数组

Google cloud platform gcloud services enable/disable--async--format=json返回空数组,google-cloud-platform,scripting,gcloud,Google Cloud Platform,Scripting,Gcloud,gcloud支持with-format选项,gcloud services enable-async返回一个命令,该命令可用于等待操作完成 例如,以下呼叫gcloud services disable servicenetworking.googleapis.com-async可能会返回类似smth的消息: Asynchronous operation is in progress... Use the following command to wait for its completion:

gcloud支持with-format选项,gcloud services enable-async返回一个命令,该命令可用于等待操作完成

例如,以下呼叫gcloud services disable servicenetworking.googleapis.com-async可能会返回类似smth的消息:

Asynchronous operation is in progress... Use the following command to wait for its completion:
 gcloud beta services operations wait operations/acf.<UID>
这里的问题是,输出返回为两行,并且不容易包含到自动脚本中。第一个想法是将-format选项与smth-like-format=json一起使用,然后使用jq,但是-format=json对gcloud服务enable/disable没有任何作用,它总是返回[]。

因此,我发现gcloud服务enable/disable没有实际输出,而是,我们使用-async接收的输出进入错误流

因此,我创建了这个小脚本,它允许从输出中获取操作ID,将其存储在文件中,然后以我们想要的任何方式进行处理:

wait_operation_id_file=$mktemp/tmp/enable_service_operation.XXXXXXX gcloud服务启用servicenetworking.googleapis.com-异步2>&1\ |grep“gcloud测试版服务运营等待”\ |sed的/*等待/'\ >>${wait_operation_id_file} wait\u id=$cat${wait\u操作\u id\u文件} gcloud服务操作wait${wait\u id} rm-force${wait\u operation\u id\u file}
我认为这是因为返回的命令是beta版的,但是您可以尝试合并输出的所有行,就像在本文中解释的那样,我相信这与返回的命令无关。一般来说,更多的是关于命令输出。-async标志不是beta选项。Thx对于链接,我相信我可以找到手动解析输出的方法,但也许gcloud团队的人就在附近。