Add Specific Projectid support feature (#7591)

This commit is contained in:
Ayush Shah 2022-09-20 17:36:10 +05:30 committed by GitHub
parent 5c0016d827
commit c522fa1de2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 1 deletions

View File

@ -219,7 +219,7 @@ def run_docker(
except MemoryError: except MemoryError:
logger.debug(traceback.format_exc()) logger.debug(traceback.format_exc())
click.secho( click.secho(
f"Please Allocate More memory to Docker.\nRecommended: 6GB\nCurrent: " f"Please Allocate More memory to Docker.\nRecommended: 6GB+\nCurrent: "
f"{round(float(dict(docker_info).get('mem_total')) / calc_gb)}", f"{round(float(dict(docker_info).get('mem_total')) / calc_gb)}",
fg="red", fg="red",
) )

View File

@ -246,3 +246,4 @@ class BigquerySource(CommonDbSourceService):
super().close() super().close()
if self.temp_credentials: if self.temp_credentials:
os.unlink(self.temp_credentials) os.unlink(self.temp_credentials)
os.environ.pop("GOOGLE_CLOUD_PROJECT", "")

View File

@ -112,6 +112,14 @@ def set_google_credentials(gcs_credentials: GCSCredentials) -> None:
return return
if isinstance(gcs_credentials.gcsConfig, GCSValues): if isinstance(gcs_credentials.gcsConfig, GCSValues):
if (
gcs_credentials.gcsConfig.projectId
and not gcs_credentials.gcsConfig.privateKey
):
logger.info(
"Overriding default projectid, using the current environment permissions authenticated via gcloud SDK."
)
return
credentials_dict = build_google_credentials_dict(gcs_credentials.gcsConfig) credentials_dict = build_google_credentials_dict(gcs_credentials.gcsConfig)
tmp_credentials_file = create_credential_tmp_file(credentials=credentials_dict) tmp_credentials_file = create_credential_tmp_file(credentials=credentials_dict)

View File

@ -12,6 +12,7 @@
""" """
Hosts the singledispatch to build source URLs Hosts the singledispatch to build source URLs
""" """
import os
from functools import singledispatch from functools import singledispatch
from urllib.parse import quote_plus from urllib.parse import quote_plus
@ -359,6 +360,8 @@ def _(connection: BigQueryConnection):
if not project_id and isinstance(connection.credentials.gcsConfig, GCSValues): if not project_id and isinstance(connection.credentials.gcsConfig, GCSValues):
project_id = connection.credentials.gcsConfig.projectId project_id = connection.credentials.gcsConfig.projectId
if project_id: if project_id:
# Setting environment variable based on project id given by user / set in ADC
os.environ["GOOGLE_CLOUD_PROJECT"] = project_id
return f"{connection.scheme.value}://{project_id}" return f"{connection.scheme.value}://{project_id}"
return f"{connection.scheme.value}://" return f"{connection.scheme.value}://"