mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-20 23:18:01 +00:00
Minor: Fixes Bigquery External Account AttributeError (#16801)
This commit is contained in:
parent
3f5bc1948d
commit
2e694b5180
@ -137,12 +137,21 @@ def set_google_credentials(gcp_credentials: GCPCredentials) -> None:
|
||||
os.environ[GOOGLE_CREDENTIALS] = str(gcp_credentials.gcpConfig.root)
|
||||
return
|
||||
|
||||
if gcp_credentials.gcpConfig.projectId is None:
|
||||
if (
|
||||
isinstance(gcp_credentials.gcpConfig, GcpCredentialsValues)
|
||||
and gcp_credentials.gcpConfig.projectId is None
|
||||
):
|
||||
logger.info(
|
||||
"No credentials available, using the current environment permissions authenticated via gcloud SDK."
|
||||
)
|
||||
return
|
||||
|
||||
if isinstance(gcp_credentials.gcpConfig, GcpExternalAccount):
|
||||
logger.info(
|
||||
"Using External account credentials to authenticate with GCP services."
|
||||
)
|
||||
return
|
||||
|
||||
if isinstance(gcp_credentials.gcpConfig, GcpCredentialsValues):
|
||||
if (
|
||||
gcp_credentials.gcpConfig.projectId
|
||||
|
@ -15,6 +15,7 @@ from unittest import TestCase
|
||||
|
||||
from pydantic import AnyUrl, SecretStr
|
||||
|
||||
from metadata.generated.schema.security.credentials.gcpCredentials import GCPCredentials
|
||||
from metadata.generated.schema.security.credentials.gcpExternalAccount import (
|
||||
GcpExternalAccount,
|
||||
)
|
||||
@ -24,7 +25,9 @@ from metadata.generated.schema.security.credentials.gcpValues import (
|
||||
from metadata.utils.credentials import (
|
||||
InvalidPrivateKeyException,
|
||||
build_google_credentials_dict,
|
||||
set_google_credentials,
|
||||
)
|
||||
from metadata.utils.logger import Loggers
|
||||
|
||||
|
||||
class TestCredentials(TestCase):
|
||||
@ -105,3 +108,11 @@ VEhPQF0i0tUU7Fl071hcYaiQoZx4nIjN+NG6p5QKbl6k
|
||||
}
|
||||
|
||||
self.assertEqual(expected_dict, build_google_credentials_dict(gcp_values))
|
||||
with self.assertLogs(Loggers.UTILS.value, level="INFO") as log:
|
||||
set_google_credentials(
|
||||
GCPCredentials(gcpConfig=gcp_values, gcpImpersonateServiceAccount=None)
|
||||
)
|
||||
self.assertIn(
|
||||
"Using External account credentials to authenticate with GCP services.",
|
||||
log.output[0],
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user