英文:
Can't define Network when creating Instance Group with Go client library?
问题
通过GCP控制台创建非托管实例组时,可以看到REST请求如下:
POST https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-d/instanceGroups
{
"name": "ig-web",
"network": "https://www.googleapis.com/compute/v1/projects/my-project/global/networks/nomad-network",
"namedPorts": [
{
"name": "http",
"port": 11080
}
]
}
然而,根据API文档和客户端库生成的代码,没有办法设置network
URL。
有人可以解释一下吗?
英文:
When creating an unmanaged instance group through GCP Console, I can see the REST request as:
POST https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-d/instanceGroups
{
"name": "ig-web",
"network": "https://www.googleapis.com/compute/v1/projects/my-project/global/networks/nomad-network",
"namedPorts": [
{
"name": "http",
"port": 11080
}
]
}
However, according to the API docs and client library generated code, one has no way to set the network
URL.
Anyone care to clarify?
答案1
得分: 0
这实际上是一个文档错误。以下代码将起作用:
op, err := gce.service.InstanceGroups.Insert(projectID, zone, &compute.InstanceGroup{
Name: name,
NamedPorts: namedPorts,
Network: networkURL}).Do()
英文:
It's actually a documentation bug. The following will work:
op, err := gce.service.InstanceGroups.Insert(projectID, zone, &compute.InstanceGroup{
Name: name,
NamedPorts: namedPorts,
Network: networkURL}).Do()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论