google-cloud-platformgoogle-cloud-repository

Best way to download Google Cloud repository


I am trying to find a solution to download my private Google source repository directly to a docker container. It's a more useful and easy method compared to git clone as most systems support wget with no extra install.

Github is supporting this

https://api.github.com/repos/<user>/<repo>/tarball

I would like to know if this download option is available in Google Cloud or any alternative method can be used for downloading code other than git clone.


Solution

  • It is not possible to directly access the files or folders of a Google Cloud Repository. Your easiest option is to clone the repository.

    If this is not possible, there is a possible workaround. Use a Google Cloud Storage bucket to upload the code there and download it later.

    For this workaround to work you will need to compress your code before uploading. Then, to download it, use wget with the command below:

    wget --header “Authorization: Bearer yourBearerToken” \  
         https://www.googleapis.com/storage/v1/b/yourBucket/o/yourFile?alt=media
    

    To obtain the Bearer Token for the API authentication read the first answer of this question:

    Is it possible to wget / curl protected files from GCS?

    The main inconvenience of this method is that if you intend to change the code of the repository often you will have to manage to automate the task of packing and uploading it to the bucket.