Skip to content

Latest commit

 

History

History
84 lines (68 loc) · 3.24 KB

CONTRIBUTING.md

File metadata and controls

84 lines (68 loc) · 3.24 KB

How to Contribute

Test Cloud Run Button's Underlying Command Locally with Local Go

  1. Download Go 1.14.x
  2. Run the tests:
    go test ./cmd/cloudshell_open
    
  3. Build the command:
    go build -o /tmp/cloudshell_open ./cmd/cloudshell_open
    
  4. To test the command:
    1. Enable the cloudresourcemanager API

    2. Enable the billing API

    3. Create a Service Account with the Cloud Run Admin, ServiceEnabler, Service Account User, and Storage Admin roles

    4. Download the JSON key

    5. Authenticate gcloud as the service account:

      export GOOGLE_APPLICATION_CREDENTIALS=PATH_TO_YOUR_SERVICE_ACCOUNT_KEY_FILE
      gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS
      export TRUSTED_ENVIRONMENT=true
      
    6. Run the button:

      (cd /tmp; ./cloudshell_open --repo_url=https://github.com/GoogleCloudPlatform/cloud-run-hello.git; rm -rf cloud-run-hello)
      

      Other cloudshell_open flags: --git_branch, --dir, --context

      Env vars you can set to avoid STDIN questions: GOOGLE_CLOUD_PROJECT GOOGLE_CLOUD_REGION

Test Cloud Run Button's Underlying Command Locally in a Container

  1. Create a Service Account in a test account

  2. Download the key json file for the new service account

  3. Build the Container

    docker build -f Dockerfile -t cloud-run-button .
    
  4. Set an env var pointing to the Service Account's JSON file:

    export KEY_FILE=PATH_TO_YOUR_SERVICE_ACCOUNT_KEY_FILE
    
  5. Run Cloud Run Button via Docker:

    docker run -it -v /var/run/docker.sock:/var/run/docker.sock \
      -v $KEY_FILE:/root/user.json \
      -e GOOGLE_APPLICATION_CREDENTIALS=/root/user.json \
      -e TRUSTED_ENVIRONMENT=true \
      --entrypoint=/bin/sh cloud-run-button -c \
      "gcloud auth activate-service-account --key-file=/root/user.json \
      --quiet && gcloud auth configure-docker --quiet && \
      /bin/cloudshell_open \
      --repo_url=https://github.com/GoogleCloudPlatform/cloud-run-hello.git"
    

Contributor License Agreement

Contributions to this project must be accompanied by a Contributor License Agreement. You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project. Head over to https://cla.developers.google.com/ to see your current agreements on file or to sign a new one.

You generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again.

Code reviews

All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult GitHub Help for more information on using pull requests.

Community Guidelines

This project follows Google's Open Source Community Guidelines.