Add support (or documentation if support already exists) for using wrench with the Cloud Spanner emulator
Opened this issue · 3 comments
WHAT
Hi, is there support for using wrench with the local Cloud Spanner emulator? So far, I haven't been able to make it work. I've tried the following:
Shell session 1
$ gcloud beta emulators spanner start
Executing: docker run -p 127.0.0.1:9010:9010 -p 127.0.0.1:9020:9020 gcr.io/cloud-spanner-emulator/emulator:0.7.3
[cloud-spanner-emulator] 2020/06/12 21:59:57 gateway.go:135: Cloud Spanner emulator running.
[cloud-spanner-emulator] 2020/06/12 21:59:57 gateway.go:136: REST server listening at 0.0.0.0:9020
[cloud-spanner-emulator] 2020/06/12 21:59:57 gateway.go:137: gRPC server listening at 0.0.0.0:9010
Shell session 2
$ $(gcloud beta emulators spanner env-init) # sets SPANNER_EMULATOR_HOST
$ ./wrench_darwin_amd64 create --directory . --project my-project --instance my-instance --database my-database
Error command: create, version: 1.0.0
Failed to execute the operation to Cloud Spanner, Either caller is missing IAM permission spanner.databases.create on resource projects/my-project/instances/my-instance, or the CreateDatabaseRequest.create_statement field is malformed and the database name could not be identified to verify Cloud IAM Conditions.
It looks like wrench
isn't picking up on the SPANNER_EMULATOR_HOST
environment variable, and therefore is failing when hitting the actual Cloud Spanner API only to find that my dummy project / instance / database doesn't exist.
I'm guessing wrench
just uses the Go client library for Cloud Spanner – which according to the emulator docs should honor the SPANNER_EMULATOR_HOST
environment variable. So I might be missing something that's needed to make this work.
WHY
We rely on the Cloud Spanner emulator for local development and are looking for a good tool to manage schema migrations. It would be great if we could start using wrench
for both local and Cloud development.
Thanks in advance.
EDIT
Perhaps googleapis/google-cloud-go#1602 is related?
I've been able to connect to the emulator by building from source / installing via go get -u github.com/cloudspannerecosystem/wrench
From the look of the binary wrench_darwin_amd64
I assume you've downloaded the latest release from github, which differs from the latest tag which go get
will clone and build.
@smacpher-myst
I've just released new version of wrench v1.0.3
which supports the emulator.
Would you please try it?
@110y Verified that using wrench_darwin_amd64
v1.0.3
works! Thank you for your help.