在使用Go客户端库创建实例组时无法定义网络吗?

huangapple go评论124阅读模式
英文:

Can't define Network when creating Instance Group with Go client library?

问题

通过GCP控制台创建非托管实例组时,可以看到REST请求如下:

  1. POST https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-d/instanceGroups
  2. {
  3. "name": "ig-web",
  4. "network": "https://www.googleapis.com/compute/v1/projects/my-project/global/networks/nomad-network",
  5. "namedPorts": [
  6. {
  7. "name": "http",
  8. "port": 11080
  9. }
  10. ]
  11. }

然而,根据API文档客户端库生成的代码,没有办法设置network URL。

有人可以解释一下吗?

英文:

When creating an unmanaged instance group through GCP Console, I can see the REST request as:

  1. POST https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-d/instanceGroups
  2. {
  3. "name": "ig-web",
  4. "network": "https://www.googleapis.com/compute/v1/projects/my-project/global/networks/nomad-network",
  5. "namedPorts": [
  6. {
  7. "name": "http",
  8. "port": 11080
  9. }
  10. ]
  11. }

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

这实际上是一个文档错误。以下代码将起作用:

  1. op, err := gce.service.InstanceGroups.Insert(projectID, zone, &compute.InstanceGroup{
  2. Name: name,
  3. NamedPorts: namedPorts,
  4. Network: networkURL}).Do()
英文:

It's actually a documentation bug. The following will work:

  1. op, err := gce.service.InstanceGroups.Insert(projectID, zone, &compute.InstanceGroup{
  2. Name: name,
  3. NamedPorts: namedPorts,
  4. Network: networkURL}).Do()

huangapple
  • 本文由 发表于 2015年12月17日 02:02:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/34319039.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定