Skip to content

Commit

Permalink
feat(sgcloudspanner): support offline mode
Browse files Browse the repository at this point in the history
Set SPANNER_EMULATOR_SKIP_PULL to avoid pulling the spanner image before
launching. This makes it possible to run the tests without internet
connectivity.

This is identical to the PR in spanner-aip-go:
einride/spanner-aip-go#277
  • Loading branch information
radhus committed Oct 27, 2022
1 parent ded671c commit 40e4aa9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tools/sgcloudspanner/emulator.go
Expand Up @@ -31,10 +31,12 @@ func RunEmulator(ctx context.Context) (_ func(), err error) {
return nil, fmt.Errorf("the Docker daemon does not seem to be running")
}
const image = "gcr.io/cloud-spanner-emulator/emulator:latest"
cmd := sgdocker.Command(ctx, "pull", image)
cmd.Stdout, cmd.Stderr = nil, nil
if err := cmd.Run(); err != nil {
return nil, err
if _, ok := os.LookupEnv("SPANNER_EMULATOR_SKIP_PULL"); !ok {
cmd := sgdocker.Command(ctx, "pull", image)
cmd.Stdout, cmd.Stderr = nil, nil
if err := cmd.Run(); err != nil {
return nil, err
}
}
var dockerRunCmd *exec.Cmd
if isRunningOnCloudBuild(ctx) {
Expand Down

0 comments on commit 40e4aa9

Please sign in to comment.