英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论