【问题标题】:Cloud function deployment issue云功能部署问题
【发布时间】:2019-10-09 10:12:39
【问题描述】:

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

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

其中一个云函数依赖使用私有github repo,

当我部署云功能时 去:github.com/myrepo/ptrie@v0.1.: git fetch -f origin refs/heads/:refs/heads/ refs/tags/:refs/tags/ em> 在 /builder/pkg/mod/cache/vcs/41e03711c0ecff6d0de8588fa6de21a2c351c59fd4b0a1b685eaaa5868c5892e:退出状态 128: 致命:无法读取“https://github.com”的用户名:终端提示已禁用

【问题讨论】:

标签: function go cloud


【解决方案1】:

您可能希望在 Github 中创建个人访问令牌,然后配置 git 以使用该令牌。

该命令如下所示:

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

之后,git 应该可以从你的私有仓库中读取数据了

【讨论】:

    【解决方案2】:

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

    @.gcloudignore

    go.mod
    go.sum
    

    endly 使用带有凭据的私有仓库的自动化工作流程可能如下所示

    @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 测试和部署自动化

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-26
      • 2018-12-29
      • 2020-10-19
      • 2021-12-01
      • 2020-10-15
      • 2021-11-17
      相关资源
      最近更新 更多