Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow users to explicitly configure universe domain #846

Merged
merged 15 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
🦉 Updates from OwlBot post-processor
  • Loading branch information
gcf-owl-bot[bot] committed Feb 2, 2024
commit 1d85992d53f7dbda573b1a334d8715e52e37fc6a
25 changes: 14 additions & 11 deletions google/cloud/logging_v2/services/config_service_v2/client.py
Expand Up @@ -497,6 +497,7 @@ def _read_environment_variables():
)
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env

@staticmethod
def _get_client_cert_source(provided_cert_source, use_cert_flag):
"""Return the client cert source to be used by the client.

Expand All @@ -515,6 +516,7 @@ def _get_client_cert_source(provided_cert_source, use_cert_flag):
client_cert_source = mtls.default_client_cert_source()
return client_cert_source

@staticmethod
def _get_api_endpoint(
api_override, client_cert_source, universe_domain, use_mtls_endpoint
):
Expand Down Expand Up @@ -589,17 +591,18 @@ def _compare_universes(
Raises:
ValueError: when client_universe does not match the universe in credentials.
"""
if credentials:
credentials_universe = credentials.universe_domain
if client_universe != credentials_universe:
default_universe = ConfigServiceV2Client._DEFAULT_UNIVERSE
raise ValueError(
"The configured universe domain "
f"({client_universe}) does not match the universe domain "
f"found in the credentials ({credentials_universe}). "
"If you haven't configured the universe domain explicitly, "
f"`{default_universe}` is the default."
)

default_universe = ConfigServiceV2Client._DEFAULT_UNIVERSE
credentials_universe = getattr(credentials, "universe_domain", default_universe)

if client_universe != credentials_universe:
raise ValueError(
"The configured universe domain "
f"({client_universe}) does not match the universe domain "
f"found in the credentials ({credentials_universe}). "
"If you haven't configured the universe domain explicitly, "
f"`{default_universe}` is the default."
)
return True

def _validate_universe_domain(self):
Expand Down
25 changes: 14 additions & 11 deletions google/cloud/logging_v2/services/logging_service_v2/client.py
Expand Up @@ -379,6 +379,7 @@ def _read_environment_variables():
)
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env

@staticmethod
def _get_client_cert_source(provided_cert_source, use_cert_flag):
"""Return the client cert source to be used by the client.

Expand All @@ -397,6 +398,7 @@ def _get_client_cert_source(provided_cert_source, use_cert_flag):
client_cert_source = mtls.default_client_cert_source()
return client_cert_source

@staticmethod
def _get_api_endpoint(
api_override, client_cert_source, universe_domain, use_mtls_endpoint
):
Expand Down Expand Up @@ -471,17 +473,18 @@ def _compare_universes(
Raises:
ValueError: when client_universe does not match the universe in credentials.
"""
if credentials:
credentials_universe = credentials.universe_domain
if client_universe != credentials_universe:
default_universe = LoggingServiceV2Client._DEFAULT_UNIVERSE
raise ValueError(
"The configured universe domain "
f"({client_universe}) does not match the universe domain "
f"found in the credentials ({credentials_universe}). "
"If you haven't configured the universe domain explicitly, "
f"`{default_universe}` is the default."
)

default_universe = LoggingServiceV2Client._DEFAULT_UNIVERSE
credentials_universe = getattr(credentials, "universe_domain", default_universe)

if client_universe != credentials_universe:
raise ValueError(
"The configured universe domain "
f"({client_universe}) does not match the universe domain "
f"found in the credentials ({credentials_universe}). "
"If you haven't configured the universe domain explicitly, "
f"`{default_universe}` is the default."
)
return True

def _validate_universe_domain(self):
Expand Down
25 changes: 14 additions & 11 deletions google/cloud/logging_v2/services/metrics_service_v2/client.py
Expand Up @@ -378,6 +378,7 @@ def _read_environment_variables():
)
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env

@staticmethod
def _get_client_cert_source(provided_cert_source, use_cert_flag):
"""Return the client cert source to be used by the client.

Expand All @@ -396,6 +397,7 @@ def _get_client_cert_source(provided_cert_source, use_cert_flag):
client_cert_source = mtls.default_client_cert_source()
return client_cert_source

@staticmethod
def _get_api_endpoint(
api_override, client_cert_source, universe_domain, use_mtls_endpoint
):
Expand Down Expand Up @@ -470,17 +472,18 @@ def _compare_universes(
Raises:
ValueError: when client_universe does not match the universe in credentials.
"""
if credentials:
credentials_universe = credentials.universe_domain
if client_universe != credentials_universe:
default_universe = MetricsServiceV2Client._DEFAULT_UNIVERSE
raise ValueError(
"The configured universe domain "
f"({client_universe}) does not match the universe domain "
f"found in the credentials ({credentials_universe}). "
"If you haven't configured the universe domain explicitly, "
f"`{default_universe}` is the default."
)

default_universe = MetricsServiceV2Client._DEFAULT_UNIVERSE
credentials_universe = getattr(credentials, "universe_domain", default_universe)

if client_universe != credentials_universe:
raise ValueError(
"The configured universe domain "
f"({client_universe}) does not match the universe domain "
f"found in the credentials ({credentials_universe}). "
"If you haven't configured the universe domain explicitly, "
f"`{default_universe}` is the default."
)
return True

def _validate_universe_domain(self):
Expand Down
13 changes: 0 additions & 13 deletions owl-bot-staging/v2/.coveragerc

This file was deleted.

33 changes: 0 additions & 33 deletions owl-bot-staging/v2/.flake8

This file was deleted.

2 changes: 0 additions & 2 deletions owl-bot-staging/v2/MANIFEST.in

This file was deleted.

49 changes: 0 additions & 49 deletions owl-bot-staging/v2/README.rst

This file was deleted.

3 changes: 0 additions & 3 deletions owl-bot-staging/v2/docs/_static/custom.css

This file was deleted.