Google-cloud-go: firestore: detect-project-id overrides the emulator

Created on 27 Jan 2020  路  4Comments  路  Source: googleapis/google-cloud-go

Client

Firestore

Environment

  • gcloud cloud-firestore-emulator 1.10.2 running with command
    gcloud beta emulators firestore start --host-port "localhost:8081"
  • Linux runtime environment, bash shell with
    export FIRESTORE_EMULATOR_HOST=localhost:8081
  • latest golang firestore server client

Code

        client, err = firestore.NewClient(context.Background(),
            "*detect-project-id*",
            options...)                                                                                                                                                                  
        if err != nil {
            return err 
        }   

Expected behavior

By default, the client lib ignores the specified Firestore project ID in a NewClient() call when it detects an emulator is running (i.e. FIRESTORE_EMULATOR_HOST env var is set) ... unless the project ID is set to the "*detect-project-id*" sentinel value. It should check for the emulator env var before checking for the "*detect-project-id*" project ID sentinel value, and ignore this value in the same way as it ignores any other project ID value. Developers using the sentinel value to auto-detect projects when running their code in GCP should not need to modify their code/configuration to use a different project ID value when using the local emulator. (I'm guessing that was the intended behavior, since it is ignored for every other value.)

Actual behavior

When the sentinel value is used, the attempt to instantiate the client throws the following error:
firestore: see the docs on DetectProjectID

Screenshots

N/A

Additional context

None

firestore p2 bug

All 4 comments

I have submitted a pull request here that fixes this. It's been there for 4 days now and no comments, so I am not sure if I've done it right.

https://code-review.googlesource.com/c/gocloud/+/51250

Thank you for sending it! I just responded on the CL, but I'd like to get one other review before merging.

Has there been any progress on this?

@rHermes apologies for the very belated response on this. @broady has a PR up with a fix if you'd like to take a look. #2598

Was this page helpful?
0 / 5 - 0 ratings