![](/img/trans.png)
[英]Got “ZIP does not support timestamps before 1980” while deploying a Go Cloud Function on GCP via Triggers
[英]When deploying GCP cloud function with go client I receive: "Error 400: Precondition check failed., failedPrecondition"
我正在嘗試使用谷歌的 go 客戶端包部署谷歌雲功能。
( https://pkg.go.dev/google.golang.org/api/cloudfunctions/v1?tab=doc#pkg-overview )
我已將其分解為我認為最相關的片段:
import (
"context"
log "github.com/sirupsen/logrus"
functions "google.golang.org/api/cloudfunctions/v1"
)
func main() {
ctx := context.Background()
CloudFunctionService, err := functions.NewService(ctx)
if err != nil {
log.Printf("Error at functions.NewService(ctx): \"%v\"\n", err)
}
FunctionSpec := functions.CloudFunction{
EntryPoint: "DeployThisFunctionEntryPoint",
EventTrigger: &functions.EventTrigger{
EventType: "google.pubsub.topic.publish",
Resource: "projects/mytestproject/topics/cloud-builds",
},
Name: "DeployThisFunction",
Runtime: "go111",
SourceRepository: &functions.SourceRepository{Url: "https://source.developers.google.com/projects/mytestproject/repos/deploythisfunction/moveable-aliases/master/paths//"},
}
CloudFunctionDeploymentService := functions.NewProjectsLocationsFunctionsService(CloudFunctionService)
createCall := CloudFunctionDeploymentService.Create("projects/mytestproject/locations/us-central1", &FunctionSpec)
resp, err := createCall.Context(ctx).Do()
if err != nil {
log.Printf("Error at createCall.Context(ctx).Do(): \"%v\"\n", err)
}
log.Printf("response createCall.Context(ctx).Do(): \"%v\"\n", resp)
}
但是,無論我如何格式化或嘗試。 我總是收到以下消息:
googleapi: Error 400: Precondition check failed., failedPrecondition
通過 google api explorer,我使用他們的身份驗證和 json 方案運行了請求,但收到了同樣的錯誤。
https://cloud.google.com/functions/docs/reference/rest/v1/projects.locations.functions/create
回復:
{
"error": {
"code": 400,
"message": "Precondition check failed.",
"status": "FAILED_PRECONDITION"
}
}
我無法弄清楚出了什么問題。 我已經開始了我自己的項目並且是管理員。 當使用 GCP 運行 go 客戶端的另一部分時,例如創建存儲、IAM 用戶、服務帳戶、數據庫,我可以使其工作並創建這些資源。
如果有人遇到過這個問題,我將不勝感激。
eventType應該匹配模式: providers/*/eventTypes/*.*.
.
例如: providers/cloud.pubsub/eventTypes/topic.publish
SourceRepository url 應該是https://source.developers.google.com/projects/*/repos/*/revisions/*/paths/
並且你有https://source.developers.google.com/projects/mytestproject/repos/deploythisfunction/moveable-aliases/master/paths//
錯誤消息說這是您配置FunctionSpec
的方式的問題,我懷疑EventTrigger
或SourceRepository
字段。
code: 400
是一個錯誤的請求,客戶端錯誤,在這種情況下是格式問題,首先要檢查的是每個雲函數文件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.