Skip to content

Cloud Source Repository Support (Draft)

Elliotte Rusty Harold edited this page Apr 17, 2018 · 1 revision

Google Cloud Source Repositories, CSR for short, are fully-featured, private Git repositories hosted by Google. CSR underpins much other GCP development including Google Cloud Container Builder, the Stackdriver debugger, GCE, and GKE. We would like these repositories to be accessible from inside Eclipse using Eclipse standard tooling, specifically EGit. That is, Eclipse should be able to:

  • Check out CSR repos into a new project
  • Pull
  • Push
  • Branch
  • View the git log

In other words, do all the usual git-like things you can do today with EGit and Github, Bitbucket, and other hosted git repos. It should not be necessary to drop out to the shell to do any of this, though that may be an interim state of development.

The stumbling block is authentication. Cloud Source Repos require a credential helper script to handle Google's two-factor authentication. This is normally supplied by the Cloud SDK like so

  1. Change your current working directory to the directory that contains your local Git repository:

    cd [REPO_DIRECTORY]
    
  2. Run the credential helper script (on Linux or MacOS X):

    git config credential.'https://source.developers.google.com'.helper gcloud.sh
    

    Or on Windows:

    git config credential.https://source.developers.google.com.helper gcloud.cmd
    

    The credential helper scripts provide the information needed by Git to connect securely to {{ product_name_short }} using your Google account credentials. You don't need to perform any additional configuration steps (for example, uploading ssh keys) to establish this secure connection.

    The gcloud command-line tool must be in your $PATH for the credential helper scripts to work.

    If you cannot use the Cloud SDK, you can manually generate static credentials. For example, if you are on a build server, you might not have access to the Cloud SDK.

Credential helpers are a standard feature of git, and can be used with the normal command line tools including git and gcloud. However EGit does not support them.

The goal is to integrate credential helper support into EGit and merge the changes upstream so it becomes a standard part of EGit.

EGit itself is built on top of JGit, a pure Java library implementing the Git version control system. We may need to first add credential helper support to JGit.