potiuk commented on a change in pull request #4170: [AIRFLOW-3275] Implement
Google Cloud SQL Query operator
URL: https://github.com/apache/incubator-airflow/pull/4170#discussion_r232597576
##########
File path: airflow/contrib/hooks/gcp_sql_hook.py
##########
@@ -261,3 +280,559 @@ def _wait_for_operation_to_complete(self, project_id,
operation_name):
# No meaningful info to return from the response in case of
success
return True
time.sleep(TIME_TO_SLEEP_IN_SECONDS)
+
+
+CLOUD_SQL_PROXY_DOWNLOAD_URL =
"https://dl.google.com/cloudsql/cloud_sql_proxy.{}.{}"
+CLOUD_SQL_PROXY_VERSION_DOWNLOAD_URL = \
+ "https://storage.googleapis.com/cloudsql-proxy/{}/cloud_sql_proxy.{}.{}"
+
+GCP_CREDENTIALS_KEY_PATH = "extra__google_cloud_platform__key_path"
+GCP_CREDENTIALS_KEYFILE_DICT = "extra__google_cloud_platform__keyfile_dict"
+
+
+class CloudSqlProxyRunner(LoggingMixin):
+ """Downloads and runs cloud-sql-proxy as subprocess of the python process.
+
+ The cloud-sql-proxy needs to be downloaded and started before we can
connect
+ to the Google Cloud SQL instance via database connection. It establishes
+ secure tunnel connection to the database - it authorizes using the
+ GCP credentials that are passed by the configuration.
+
+ More details about the proxy can be found here:
+ https://cloud.google.com/sql/docs/mysql/sql-proxy
+
+ """
+ def __init__(self,
+ path_prefix,
+ instance_specification,
+ gcp_conn_id='google_cloud_default',
+ project_id=None,
+ sql_proxy_version=None,
+ sql_proxy_binary_path=None):
+ """
+ Creates the proxy runner class.
+
+ :param path_prefix: unique path prefix where proxy will be downloaded
and
+ directories created for unix sockets.
Review comment:
Yes. I reviewed it everywhere. I think I have some automated indentation. I
updated it everywhere and regenerated the docs/reviewed it.
----------------------------------------------------------------
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