为什么 cloud.google.com/go/functions 的 Golang 包无法列出 gen2 的 Golang 函数?

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

Why is cloud.google.com/go/functions Golang package not able to List gen2 golang functions

问题

我正在尝试使用Golang SDK通过服务帐号JSON列出函数。返回的迭代器包含关于gen1函数的信息,但不包含gen2函数的信息。请在本地运行时添加服务帐号JSON,链接为https://go.dev/play/p/ZwZ-jGscFCl。

相同的服务帐号凭据在使用gcloud二进制文件时可以获取所有函数。

Golang SDK是否存在问题?

英文:

I am trying to listFunctions via golang SDK using service account json .
The return iterator have information about gen1 functions but not gen2.
https://go.dev/play/p/ZwZ-jGscFCl - Please add service account json for running in local.

The same service account credentials are used for with gcloud binary. It is able to fetch all the functions.

Is there any issue with golang SDK?

答案1

得分: 1

我有1个答案和1个备注

答案:

使用Golang中的API v2而不是V1。V1不支持环境生成变量。这是V2的API规范。看看环境枚举。

自从两周以来,V2 API也支持gen1函数。你可以同时使用同一个库获取所有内容。

备注:

你不需要,也不应该在本地使用服务账号密钥文件。你的用户账号(带或不带服务账号模拟)就是为此而创建的。看看我在那个问题中的评论

英文:

I have 1 answer and 1 remark

Answer:

Use the v2 of the API in Golang and not the V1. The V1 does not support environment generation variable. Here the API spec of the V2. Look at the environment enum.

Since 2 weeks, the V2 API also supports gen1 functions. You can get all in the same time with the same library.

Remark:

You don't need and you shouldn't (mustn't) use service account key file locally. Your user account (with or without service account impersonation) is made for that. Look at my comments in that questions

huangapple
  • 本文由 发表于 2023年2月6日 21:19:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75361836.html
匿名

发表评论

匿名网友

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

确定