nuclearpinguin commented on a change in pull request #6299: [AIRFLOW-5631]
Change way of running GCP system tests
URL: https://github.com/apache/airflow/pull/6299#discussion_r333630818
##########
File path: airflow/gcp/hooks/base.py
##########
@@ -323,8 +341,63 @@ def provide_gcp_credential_file_as_context(self):
pass
yield conf_file
finally:
- if current_env_state is None:
- if CREDENTIALS in os.environ:
- del os.environ[CREDENTIALS]
- else:
- os.environ[CREDENTIALS] = current_env_state
+ self.restore_env_variable(current_env_state)
+
+ @staticmethod
+ def build_gcp_conn(
+ key_file_path: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ project_id: Optional[str] = None,
+ gcp_conn_id: str = 'google_cloud_default'
+ ) -> str:
+ """
+ Builds a variable that can be used as
`AIRFLOW_CONN_GOOGLE_CLOUD_DEFAULT` with provided service key,
+ scopes and project id.
+ """
+ conn = "google-cloud-platform://?"
+ extras = "extra__{}".format(gcp_conn_id)
+ scopes = scopes or _DEFAULT_SCOPES
+ project_id = project_id or os.environ.get(PROJECT)
+
+ if key_file_path:
+ conn += "{}__key_path={}&".format(extras, key_file_path)
+ if scopes:
+ conn += "{}__scope={}&".format(extras, ",".join(scopes))
+ if project_id:
+ conn += "{}__project={}".format(extras, project_id)
+
+ return conn
+
+ @staticmethod
+ def _resolve_gcp_keys_path() -> str:
+ path = os.environ.get('GCP_CONFIG_DIR', "/config")
Review comment:
What do you mean?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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