Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Project import generated by Copybara. (#20)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 162346017
  • Loading branch information
Philmod authored Jul 28, 2017
1 parent 3ba53e1 commit 844ab61
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 25 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ and integration into local build and test workflows.

----

## Using Local Builder

### Prerequisites
- gcloud
- docker
- go (if you build the tool yourself)

If you want to access private GCR during the local build (either pulling or
pushing an image), use the
[Docker credential helper for GCR users](https://github.com/GoogleCloudPlatform/docker-credential-gcr).

## Developing Local Builder

To build and develop Local Builder, you need a working [Go environment].
Expand Down
5 changes: 5 additions & 0 deletions integration_tests/gce_startup_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ function install_sdk() {
# We use the public installer.
rm -rf "$CLOUDSDK_INSTALL_DIR/google-cloud-sdk"
curl https://sdk.cloud.google.com | bash || exit

# Install needed components.
gcloud components install docker-credential-gcr --quiet || exit
}
install_sdk&
export PATH=$PATH:/usr/lib/google-cloud-sdk/bin

# add the install_sdk PID to the list for waiting.
pids="$! $pids"

Expand Down
3 changes: 3 additions & 0 deletions integration_tests/test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Set project.
gcloud config set project $PROJECT_ID

# Configure docker with gcr credentials.
docker-credential-gcr configure-docker || exit

# Flags tests.
container-builder-local --version || exit
container-builder-local --help || exit
Expand Down
50 changes: 25 additions & 25 deletions localbuilder_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,33 +187,33 @@ func run(source string) error {
}
metadataUpdater.SetProjectInfo(projectInfo)

// Set initial Docker credentials.
tok, err := gcloud.AccessToken(r)
if err != nil {
return fmt.Errorf("Error getting access token to set docker credentials: %v", err)
}
if err := b.SetDockerAccessToken(tok); err != nil {
return fmt.Errorf("Error setting docker credentials: %v", err)
}

// Write initial docker credentials for GCR. This writes the initial
// ~/.docker/config.json which is made available to build steps.

go func() {
for ; ; time.Sleep(tokenRefreshDur) {
tok, err := gcloud.AccessToken(r)
if err != nil {
log.Printf("Error getting access token to update docker credentials: %v", err)
continue
}
if err := b.UpdateDockerAccessToken(tok); err != nil {
log.Printf("Error updating docker credentials: %v", err)
}
}
}()

go supplyTokenToMetadata(metadataUpdater, r)
}

// Set initial Docker credentials.
tok, err := gcloud.AccessToken(r)
if err != nil {
return fmt.Errorf("Error getting access token to set docker credentials: %v", err)
}
if err := b.SetDockerAccessToken(tok); err != nil {
return fmt.Errorf("Error setting docker credentials: %v", err)
}

// Write initial docker credentials for GCR. This writes the initial
// ~/.docker/config.json which is made available to build steps.

go func() {
for ; ; time.Sleep(tokenRefreshDur) {
tok, err := gcloud.AccessToken(r)
if err != nil {
log.Printf("Error getting access token to update docker credentials: %v", err)
continue
}
if err := b.UpdateDockerAccessToken(tok); err != nil {
log.Printf("Error updating docker credentials: %v", err)
}
}
}()
}

b.Start()
Expand Down

0 comments on commit 844ab61

Please sign in to comment.