kaxil commented on a change in pull request #4500: [AIRFLOW-3681] All GCP
operators have now optional GCP Project ID
URL: https://github.com/apache/airflow/pull/4500#discussion_r247324591
##########
File path: airflow/contrib/hooks/gcp_sql_hook.py
##########
@@ -682,15 +703,22 @@ class CloudSqlDatabaseHook(BaseHook):
* **sslcert** - Path to client certificate to authenticate when SSL is
used.
* **sslkey** - Path to client private key to authenticate when SSL is used.
* **sslrootcert** - Path to server's certificate to authenticate when SSL
is used.
+
+ :param gcp_cloudsql_conn_id: URL of the connection
+ :type gcp_cloudsql_conn_id: str
+ :param default_gcp_project_id: Default project id used if project_id not
specified
+ in the connection URL
+ :type default_gcp_project_id: str
"""
_conn = None
- def __init__(self, gcp_cloudsql_conn_id='google_cloud_sql_default'):
+ def __init__(self, gcp_cloudsql_conn_id='google_cloud_sql_default',
+ default_gcp_project_id=None):
super(CloudSqlDatabaseHook, self).__init__(source=None)
self.gcp_cloudsql_conn_id = gcp_cloudsql_conn_id
self.cloudsql_connection =
self.get_connection(self.gcp_cloudsql_conn_id)
self.extras = self.cloudsql_connection.extra_dejson
- self.project_id = self.extras.get('project_id')
+ self.project_id = self.extras.get('project_id', default_gcp_project_id)
Review comment:
It already gets the `project_id` from the connection. So, we don't need to
add another default value
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services