云功能部署问题

时间:2019-05-22 21:04:54

标签: function go cloud

部署云功能时,出现以下错误。

我正在使用go mod,并且能够从我的沙箱中构建并运行所有集成测试,

其中一个云函数依赖项使用私有github存储库

当我部署云功能时 转到:github.com/myrepo/ptrie@v0.1 .: git fetch -f origin refs / heads / :refs / heads / refs / tags / :refs / tags / :退出状态128:   致命:无法读取“ https://github.com”的用户名:终端提示已禁用

2 个答案:

答案 0 :(得分:0)

您可能想在Github中创建一个个人访问令牌,然后将git配置为使用该令牌。

该命令如下所示:

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

之后,git应该能够从您的私人仓库中读取

答案 1 :(得分:0)

如何最终使用自动化的云功能构建,在这种情况下,您会 与供应商一起使用go mod,您的私人仓库将被添加到供应商文件夹中, 确保将.gcloudignore添加为不限制go.mod,go.sum

@。gcloudignore

go.mod
go.sum

最终使用带有凭据的私有存储库的自动化工作流程可能如下所示

@ 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}/

最后检查cloud function e2e测试和部署自动化