1

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,

One of the cloud function dependency uses private github repo,

When I deploy cloud function go: github.com/myrepo/[email protected].: 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

1

2 Answers 2

0

You might want to create a personal access token within Github and then configure git to use that token.

That command would look like this:

git config --global url."https://{YOUR TOKEN}:[email protected]/".insteadOf "https://github.com/"

After that, git should be able to read from your private repo

Sign up to request clarification or add additional context in comments.

Comments

0

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

@.gcloudignore

go.mod
go.sum

The automation workflow with endly that uses private repo with credentials may look like the following

@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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.