Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

larkee
Copy link
Contributor

@larkee larkee commented May 21, 2020

Currently, we do not support setting the emulator host outside of the env flag SPANNER_EMULATOR_HOST.

This PR allows users to set the emulator host by using the api_endpoint in client_options with google.auth.credentials.AnonymousCredentials

e.g.

from google.auth.credentials import AnonymousCredentials
from google.cloud import spanner

cred = AnonymousCredentials()
client_options = {'api_endpoint': '0.0.0.0:9010'}
client = spanner.Client(
    credentials=cred,
    client_options=client_options,
    project='emulator-project'
)

@larkee larkee requested a review from hengfengli May 21, 2020 04:40
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 21, 2020
else:
self._client_options = client_options

if isinstance(credentials, AnonymousCredentials):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for other libraries, we may have done the opposite.
If the emulator_env_variable is set, we hard-code anonymous/null credentials for the emulator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated it to set AnonymousCredentials when the env var is set.

Copy link

@hengfengli hengfengli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A few comments.

@larkee larkee requested review from hengfengli and snehashah16 May 25, 2020 04:58
Copy link

@hengfengli hengfengli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@larkee larkee added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 26, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 26, 2020
@larkee larkee merged commit b22630b into googleapis:master May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants