简体   繁体   English

云功能部署问题

[英]Cloud function deployment issue

When I deploy cloud function I get the following error. 当我部署云功能时,我收到以下错误。

I am using go mod and I am able to build and run all the integration test from my sandbox, 我正在使用go mod,我能够从我的沙箱构建并运行所有集成测试,

One of the cloud function dependency uses private github repo, 其中一个云函数依赖使用私有github repo,

When I deploy cloud function go: github.com/myrepo/ptrie@v0.1.: git fetch -f origin refs/heads/ :refs/heads/ refs/tags/ :refs/tags/ in /builder/pkg/mod/cache/vcs/41e03711c0ecff6d0de8588fa6de21a2c351c59fd4b0a1b685eaaa5868c5892e: exit status 128: fatal: could not read Username for ' https://github.com ': terminal prompts disabled 当我部署云功能时go:github.com/myrepo/ptrie@v0.1。:git fetch -f origin refs / heads / :refs / heads / refs / tags / :refs / tags / in / builder / pkg / mod / cache / vcs / 41e03711c0ecff6d0de8588fa6de21a2c351c59fd4b0a1b685eaaa5868c5892e:退出状态128:致命:无法读取“ https://github.com ”的用户名:终端提示被禁用

You might want to create a personal access token within Github and then configure git to use that token. 您可能希望在Github中创建个人访问令牌,然后配置git以使用该令牌。

That command would look like this: 该命令看起来像这样:

git config --global url."https://{YOUR TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/"

After that, git should be able to read from your private repo 在那之后,git应该能够从您的私人仓库中读取

How about using endly to automate your cloud function build, in this case you would use go mod with vendor, where you private repo would be added to vendor folder, Make sure that you add .gcloudignore to not incliude go.mod, go.sum 如何使用endly自动化你的云功能构建,在这种情况下你会使用go mod与供应商,你的私人仓库将被添加到供应商文件夹,确保你添加.gcloudignore不包括go.mod,go.sum

@.gcloudignore @ .gcloudignore

go.mod
go.sum

The automation workflow with endly that uses private repo with credentials may look like the following 最终使用具有凭证的私人仓库的自动化工作流程可能如下所示

@deploy.yaml @ deploy.yaml

init:
  appPath: $WorkingDirectory(.)
  target:
    URL: ssh://127.0.0.1/
    credentials: localhost
  myGitSecret: ${secrets.private-git}
pipeline:
  secretInfo:
    action: print
    comments: print git credentials (debuging only_
    message: $AsJSON($myGitSecret)

  package:
    action: exec:run
    comments: vendor build for deployment speedup
    target: $target
    checkError: true
    terminators:
      - Password
      - Username
    secrets:
      #secret var alias:  secret file i.e ~/.secret/private-git.json
      gitSecrets: private-git
    commands:
      - export GIT_TERMINAL_PROMPT=1
      - export GO111MODULE=on
      - unset GOPATH
      - cd ${appPath}/
      - go mod vendor
      - '${cmd[3].stdout}:/Username/? $gitSecrets.Username'
      - '${output}:/Password/? $gitSecrets.Password'

  deploy:
    action: gcp/cloudfunctions:deploy
    '@name': MyFn
    timeout: 540s
    availableMemoryMb: 2048
    entryPoint: MyFn
    runtime: go111
    eventTrigger:
      eventType: google.storage.object.finalize
      resource: projects/_/buckets/${matcherConfig.Bucket}
    source:
      URL: ${appPath}/

Finally check out cloud function e2e testing and deployment automation 最后查看云功能 e2e测试和部署自动化

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM